docs/src/content/en/models/providers/deepinfra.mdx
Access 27 Deep Infra models through Mastra's model router. Authentication is handled automatically using the DEEPINFRA_API_KEY environment variable.
Learn more in the Deep Infra documentation.
DEEPINFRA_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: "deepinfra/MiniMaxAI/MiniMax-M2"
});
// 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);
}
<ProviderModelsTable models={[ { "model": "deepinfra/anthropic/claude-3-7-sonnet-latest", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 200000, "maxOutput": 64000, "inputCost": 3.3, "outputCost": 16.5 }, { "model": "deepinfra/anthropic/claude-4-opus", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 200000, "maxOutput": 32000, "inputCost": 16.5, "outputCost": 82.5 }, { "model": "deepinfra/deepseek-ai/DeepSeek-R1-0528", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": false, "reasoning": true, "contextWindow": 163840, "maxOutput": 64000, "inputCost": 0.5, "outputCost": 2.15 }, { "model": "deepinfra/deepseek-ai/DeepSeek-V3.2", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 163840, "maxOutput": 64000, "inputCost": 0.26, "outputCost": 0.38 }, { "model": "deepinfra/meta-llama/Llama-3.1-70B-Instruct", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 131072, "maxOutput": 16384, "inputCost": 0.4, "outputCost": 0.4 }, { "model": "deepinfra/meta-llama/Llama-3.1-70B-Instruct-Turbo", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 131072, "maxOutput": 16384, "inputCost": 0.4, "outputCost": 0.4 }, { "model": "deepinfra/meta-llama/Llama-3.1-8B-Instruct", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 131072, "maxOutput": 16384, "inputCost": 0.02, "outputCost": 0.05 }, { "model": "deepinfra/meta-llama/Llama-3.1-8B-Instruct-Turbo", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 131072, "maxOutput": 16384, "inputCost": 0.02, "outputCost": 0.03 }, { "model": "deepinfra/meta-llama/Llama-3.3-70B-Instruct-Turbo", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 131072, "maxOutput": 16384, "inputCost": 0.1, "outputCost": 0.32 }, { "model": "deepinfra/meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 1000000, "maxOutput": 16384, "inputCost": 0.15, "outputCost": 0.6 }, { "model": "deepinfra/meta-llama/Llama-4-Scout-17B-16E-Instruct", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 10000000, "maxOutput": 16384, "inputCost": 0.08, "outputCost": 0.3 }, { "model": "deepinfra/MiniMaxAI/MiniMax-M2", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 262144, "maxOutput": 32768, "inputCost": 0.254, "outputCost": 1.02 }, { "model": "deepinfra/MiniMaxAI/MiniMax-M2.1", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 196608, "maxOutput": 196608, "inputCost": 0.28, "outputCost": 1.2 }, { "model": "deepinfra/MiniMaxAI/MiniMax-M2.5", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 204800, "maxOutput": 131072, "inputCost": 0.27, "outputCost": 0.95 }, { "model": "deepinfra/moonshotai/Kimi-K2-Instruct", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 131072, "maxOutput": 32768, "inputCost": 0.5, "outputCost": 2 }, { "model": "deepinfra/moonshotai/Kimi-K2-Instruct-0905", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 262144, "maxOutput": 262144, "inputCost": 0.4, "outputCost": 2 }, { "model": "deepinfra/moonshotai/Kimi-K2-Thinking", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 32768, "inputCost": 0.47, "outputCost": 2 }, { "model": "deepinfra/moonshotai/Kimi-K2.5", "imageInput": true, "audioInput": false, "videoInput": true, "toolUsage": true, "reasoning": true, "contextWindow": 262144, "maxOutput": 32768, "inputCost": 0.5, "outputCost": 2.8 }, { "model": "deepinfra/openai/gpt-oss-120b", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 16384, "inputCost": 0.05, "outputCost": 0.24 }, { "model": "deepinfra/openai/gpt-oss-20b", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 131072, "maxOutput": 16384, "inputCost": 0.03, "outputCost": 0.14 }, { "model": "deepinfra/Qwen/Qwen3-Coder-480B-A35B-Instruct", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 262144, "maxOutput": 66536, "inputCost": 0.4, "outputCost": 1.6 }, { "model": "deepinfra/Qwen/Qwen3-Coder-480B-A35B-Instruct-Turbo", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": false, "contextWindow": 262144, "maxOutput": 66536, "inputCost": 0.3, "outputCost": 1.2 }, { "model": "deepinfra/zai-org/GLM-4.6", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 204800, "maxOutput": 131072, "inputCost": 0.43, "outputCost": 1.74 }, { "model": "deepinfra/zai-org/GLM-4.6V", "imageInput": true, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 204800, "maxOutput": 131072, "inputCost": 0.3, "outputCost": 0.9 }, { "model": "deepinfra/zai-org/GLM-4.7", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 202752, "maxOutput": 16384, "inputCost": 0.43, "outputCost": 1.75 }, { "model": "deepinfra/zai-org/GLM-4.7-Flash", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 202752, "maxOutput": 16384, "inputCost": 0.06, "outputCost": 0.4 }, { "model": "deepinfra/zai-org/GLM-5", "imageInput": false, "audioInput": false, "videoInput": false, "toolUsage": true, "reasoning": true, "contextWindow": 202752, "maxOutput": 16384, "inputCost": 0.8, "outputCost": 2.56 } ]} />
const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
id: "deepinfra/MiniMaxAI/MiniMax-M2",
apiKey: process.env.DEEPINFRA_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
? "deepinfra/zai-org/GLM-5"
: "deepinfra/MiniMaxAI/MiniMax-M2";
}
});
This provider can also be installed directly as a standalone package, which can be used instead of the Mastra model router string. View the package documentation for more details.
npm install @ai-sdk/deepinfra
For detailed provider-specific documentation, see the AI SDK Deep Infra provider docs.