docs/src/content/en/models/providers/zhipuai-coding-plan.mdx
Access 10 Zhipu AI Coding Plan models through Mastra's model router. Authentication is handled automatically using the ZHIPU_API_KEY environment variable.
Learn more in the Zhipu AI Coding Plan documentation.
ZHIPU_API_KEY=your-api-key
import { Agent } from "@mastra/core/agent";
const agent = new Agent({
id: "my-agent",
name: "My Agent",
instructions: "You are a helpful assistant",
model: "zhipuai-coding-plan/glm-4.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);
}
:::info
Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the Zhipu AI Coding Plan documentation for details.
:::
<ProviderModelsTable models={[ { "model": "zhipuai-coding-plan/glm-4.5", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 98304, "inputCost": null, "outputCost": null }, { "model": "zhipuai-coding-plan/glm-4.5-air", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 98304, "inputCost": null, "outputCost": null }, { "model": "zhipuai-coding-plan/glm-4.5-flash", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 98304, "inputCost": null, "outputCost": null }, { "model": "zhipuai-coding-plan/glm-4.5v", "imageInput": true, "audioInput": false, "videoInput": true, "toolUsage": true, "reasoning": true, "contextWindow": 64000, "maxOutput": 16384, "inputCost": null, "outputCost": null }, { "model": "zhipuai-coding-plan/glm-4.6", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 204800, "maxOutput": 131072, "inputCost": null, "outputCost": null }, { "model": "zhipuai-coding-plan/glm-4.6v", "imageInput": true, "audioInput": false, "videoInput": true, "toolUsage": true, "reasoning": true, "contextWindow": 128000, "maxOutput": 32768, "inputCost": null, "outputCost": null }, { "model": "zhipuai-coding-plan/glm-4.6v-flash", "imageInput": true, "audioInput": false, "videoInput": true, "toolUsage": true, "reasoning": true, "contextWindow": 128000, "maxOutput": 32768, "inputCost": null, "outputCost": null }, { "model": "zhipuai-coding-plan/glm-4.7", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 204800, "maxOutput": 131072, "inputCost": null, "outputCost": null }, { "model": "zhipuai-coding-plan/glm-5", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 204800, "maxOutput": 131072, "inputCost": null, "outputCost": null }, { "model": "zhipuai-coding-plan/glm-5-turbo", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 200000, "maxOutput": 131072, "inputCost": null, "outputCost": null } ]} />
const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
url: "https://open.bigmodel.cn/api/coding/paas/v4",
id: "zhipuai-coding-plan/glm-4.5",
apiKey: process.env.ZHIPU_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});
const agent = new Agent({
id: "dynamic-agent",
name: "Dynamic Agent",
model: ({ requestContext }) => {
const useAdvanced = requestContext.task === "complex";
return useAdvanced
? "zhipuai-coding-plan/glm-5-turbo"
: "zhipuai-coding-plan/glm-4.5";
}
});