跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

CommandCode logoCommandCode

Access 71 CommandCode models through Mastra's model router. Authentication is handled automatically using the CMD_API_KEY environment variable.

Learn more in the CommandCode documentation.

.env
CMD_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: "commandcode/MiniMaxAI/MiniMax-M2.5"
});

// 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);
}
备注

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

Models
Models的直接链接

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
commandcode/claude-fable-51.0M$10$50
commandcode/claude-fable-5-11.0M$10$50
commandcode/claude-haiku-4-5-20251001200K$1$5
commandcode/claude-haiku-5-51.0M$0.10$0.50
commandcode/claude-opus-4-71.0M$5$25
commandcode/claude-opus-4-81.0M$5$25
commandcode/claude-opus-51.0M$5$25
commandcode/claude-opus-5-51.0M$4$20
commandcode/claude-sonnet-4-61.0M$3$15
commandcode/claude-sonnet-51.0M$2$10
commandcode/claude-sonnet-5-51.0M$2$10
commandcode/deepseek/deepseek-v4-flash1.0M$0.15$0.60
commandcode/deepseek/deepseek-v4-flash-fast1.0M$0.28$0.56
commandcode/deepseek/deepseek-v4-flash-vision-exp1.0M$0.15$0.60
commandcode/deepseek/deepseek-v4-pro1.0M$0.66$2
commandcode/deepseek/deepseek-v4.1-flash1.0M$0.15$0.60
commandcode/deepseek/deepseek-v4.1-flash-fast1.0M$0.16$0.58
commandcode/google/gemini-3.1-flash-lite1.0M$0.25$2
commandcode/google/gemini-3.5-flash1.0M$2$9
commandcode/google/gemini-3.5-flash-lite1.0M$0.30$3
commandcode/google/gemini-3.6-flash1.0M$2$8
commandcode/google/gemini-3.7-flash1.0M$2$8
commandcode/google/gemini-3.8-flash1.0M$2$8
commandcode/google/gemini-4-argon1.0M$2$10
commandcode/gpt-5.3-codex400K$2$8
commandcode/gpt-5.4400K$3$15
commandcode/gpt-5.4-mini400K$0.75$5
commandcode/gpt-5.5400K$5$30
commandcode/gpt-5.6-luna1.1M$0.20$1
commandcode/gpt-5.6-sol1.1M$5$30
commandcode/gpt-5.6-terra1.1M$2$12
commandcode/gpt-6-astra1.1M$10$50
commandcode/gpt-6-luna1.1M$0.10$0.50
commandcode/gpt-6-sol1.1M$2$10
commandcode/gpt-6.1-sol1.1M$2$10
commandcode/inclusionai/ling-3.1-flash:free262K——
commandcode/meta/muse-spark-1.11.0M$1$4
commandcode/meta/muse-spark-1.21.0M$1$4
commandcode/meta/muse-spark-1.2-contributor1.0M$0.10$0.20
commandcode/meta/muse-spark-1.31.0M$1$4
commandcode/meta/muse-spark-1.3-contributor1.0M$0.10$0.20
commandcode/meta/muse-wonder-1.01.0M$4$20
commandcode/MiniMaxAI/MiniMax-M2.5200K$0.30$1
commandcode/MiniMaxAI/MiniMax-M2.7200K$0.30$1
commandcode/MiniMaxAI/MiniMax-M31.0M$0.30$1
commandcode/mistral/mistral-large-4524K$1$4
commandcode/moonshotai/Kimi-K2.7-Code256K$0.95$4
commandcode/moonshotai/Kimi-K2.7-Code-Highspeed262K$2$8
commandcode/moonshotai/Kimi-K31.0M$3$15
commandcode/nvidia/nemotron-3-ultra-550b-a55b1.0M$0.60$2
commandcode/Qwen/Qwen3.8-27B262K$0.40$3
commandcode/Qwen/Qwen3.8-Flash1.0M$0.16$0.47
commandcode/Qwen/Qwen3.8-Max1.0M$2$6
commandcode/Qwen/Qwen3.8-Max-09021.0M$2$6
commandcode/Qwen/Qwen3.8-Omni-Flash1.0M$0.15$0.47
commandcode/sakana/fugu-ultra1.0M$5$30
commandcode/stepfun/Step-3.5-Flash256K$0.09$0.30
commandcode/stepfun/Step-3.7-Flash256K$0.20$1
commandcode/stepfun/Step-5-Preview1.0M$1$3
commandcode/tencent/hy3-paid256K$0.14$0.58
commandcode/tencent/hy4-preview1.0M$0.83$3
commandcode/thinkingmachines/inkling256K$1$4
commandcode/thinkingmachines/inkling-small1.0M$0.50$1
commandcode/xai/grok-4.5500K$2$6
commandcode/xai/grok-4.6500K$2$6
commandcode/xai/grok-4.7500K$2$6
commandcode/z-ai/glm-5.3-flash1.0M$0.15$0.50
commandcode/z-ai/glm-5.3-flashx1.0M$0.37$1
commandcode/zai-org/GLM-5.21.0M$1$4
commandcode/zai-org/GLM-5.2-Fast1.0M$3$10
commandcode/zai-org/GLM-5.31.0M$1$4
71 available models

Model availability, capabilities, context windows, and pricing are sourced from models.dev and may change.

Advanced configuration
Advanced configuration的直接链接

Custom headers
Custom headers的直接链接

src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
url: "https://api.commandcode.ai/provider/v1",
id: "commandcode/MiniMaxAI/MiniMax-M2.5",
apiKey: process.env.CMD_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});

Dynamic model selection
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
? "commandcode/zai-org/GLM-5.3"
: "commandcode/MiniMaxAI/MiniMax-M2.5";
}
});