Deep Infra
Access 15 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.
.env
DEEPINFRA_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: "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);
}
ModelsDirect link to Models
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|---|---|
deepinfra/anthropic/claude-3-7-sonnet-latest | 200K | $3 | $17 | |||||
deepinfra/anthropic/claude-4-opus | 200K | $17 | $83 | |||||
deepinfra/deepseek-ai/DeepSeek-R1-0528 | 164K | $0.50 | $2 | |||||
deepinfra/deepseek-ai/DeepSeek-V3.2 | 164K | $0.26 | $0.38 | |||||
deepinfra/MiniMaxAI/MiniMax-M2 | 262K | $0.25 | $1 | |||||
deepinfra/MiniMaxAI/MiniMax-M2.1 | 197K | $0.28 | $1 | |||||
deepinfra/moonshotai/Kimi-K2-Instruct | 131K | $0.50 | $2 | |||||
deepinfra/moonshotai/Kimi-K2-Thinking | 131K | $0.47 | $2 | |||||
deepinfra/moonshotai/Kimi-K2.5 | 262K | $0.50 | $3 | |||||
deepinfra/openai/gpt-oss-120b | 131K | $0.05 | $0.24 | |||||
deepinfra/openai/gpt-oss-20b | 131K | $0.03 | $0.14 | |||||
deepinfra/Qwen/Qwen3-Coder-480B-A35B-Instruct | 262K | $0.40 | $2 | |||||
deepinfra/Qwen/Qwen3-Coder-480B-A35B-Instruct-Turbo | 262K | $0.30 | $1 | |||||
deepinfra/zai-org/GLM-4.7 | 203K | $0.43 | $2 | |||||
deepinfra/zai-org/GLM-4.7-Flash | 203K | $0.06 | $0.40 |
Advanced ConfigurationDirect link to Advanced Configuration
Custom HeadersDirect link to Custom Headers
src/mastra/agents/my-agent.ts
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"
}
}
});
Dynamic Model SelectionDirect 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
? "deepinfra/zai-org/GLM-4.7-Flash"
: "deepinfra/MiniMaxAI/MiniMax-M2";
}
});
Direct Provider InstallationDirect link to Direct Provider Installation
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
- pnpm
- Yarn
- Bun
npm install @ai-sdk/deepinfra
pnpm add @ai-sdk/deepinfra
yarn add @ai-sdk/deepinfra
bun add @ai-sdk/deepinfra
For detailed provider-specific documentation, see the AI SDK Deep Infra provider docs.