Skip to main content

TokenGo logoTokenGo

Access 13 TokenGo models through Mastra's model router. Authentication is handled automatically using the TOKENGO_API_KEY environment variable.

Learn more in the TokenGo documentation.

.env
TOKENGO_API_KEY=your-api-key
src/mastra/agents/my-agent.ts
import { Agent } from "@mastra/core/agent";

const agent = new Agent({
id: "my-agent",
name: "My Agent",
instructions: "You are a helpful assistant",
model: "tokengo/deepseek/deepseek-v3.1"
});

// Generate a response
const response = await agent.generate("Hello!");

// Stream a response
const stream = await agent.stream("Tell me a story");
for await (const chunk of stream) {
console.log(chunk);
}
note

Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the TokenGo documentation for details.

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
tokengo/deepseek/deepseek-v3.1131K$0.19$0.71
tokengo/deepseek/deepseek-v3.2128K$0.22$0.33
tokengo/deepseek/deepseek-v4-flash1.0M$0.10$0.20
tokengo/deepseek/deepseek-v4-pro1.0M$0.43$0.87
tokengo/minimax/minimax-m2.5205K$0.30$1
tokengo/moonshotai/kimi-k2.6262K$0.95$4
tokengo/moonshotai/kimi-k31.0M$3$15
tokengo/qwen/qwen3.5-397b-a17b262K$0.40$3
tokengo/z-ai/glm-5205K$0.89$3
tokengo/z-ai/glm-5.1200K$1$4
tokengo/z-ai/glm-5.21.0M$1$4
tokengo/z-ai/glm-5.31.0M$1$4
tokengo/z-ai/glm-5.3-flash1.0M$0.07$0.03
13 available models

Advanced configuration
Direct link to Advanced configuration

Custom headers
Direct link to Custom headers

src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
url: "https://api.tokengo.com/v1",
id: "tokengo/deepseek/deepseek-v3.1",
apiKey: process.env.TOKENGO_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});

Dynamic model selection
Direct link to Dynamic model selection

src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "dynamic-agent",
name: "Dynamic Agent",
model: ({ requestContext }) => {
const useAdvanced = requestContext.task === "complex";
return useAdvanced
? "tokengo/z-ai/glm-5.3-flash"
: "tokengo/deepseek/deepseek-v3.1";
}
});
On this page