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

Deep Infra logoDeep Infra

Access 76 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/ByteDance/Seed-2.0-code"
});

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

Models
Models的直接链接

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
deepinfra/anthropic/claude-fable-51.0M$10$50
deepinfra/ByteDance/Seed-2.0-code256K$0.50$3
deepinfra/ByteDance/Seed-2.0-mini256K$0.10$0.40
deepinfra/ByteDance/Seed-2.0-pro256K$0.50$3
deepinfra/deepseek-ai/DeepSeek-R1-0528164K$0.50$2
deepinfra/deepseek-ai/DeepSeek-V3164K$0.32$0.89
deepinfra/deepseek-ai/DeepSeek-V3.1164K$0.25$0.95
deepinfra/deepseek-ai/DeepSeek-V3.2164K$0.26$0.38
deepinfra/deepseek-ai/DeepSeek-V4-Flash1.0M$0.09$0.18
deepinfra/deepseek-ai/DeepSeek-V4-Flash-07311.0M$0.06$0.18
deepinfra/deepseek-ai/DeepSeek-V4-Flash-Vision-Exp1.0M$0.44$1
deepinfra/deepseek-ai/DeepSeek-V4-Pro1.0M$1$3
deepinfra/deepseek-ai/DeepSeek-V4-Pro-08131.0M$1$3
deepinfra/deepseek-ai/DeepSeek-V4.1-Flash1.0M$0.20$0.60
deepinfra/deepseek-ai/DeepSeek-V4.1-Flash-10171.0M$0.20$0.60
deepinfra/google/gemma-3-12b-it131K$0.05$0.15
deepinfra/google/gemma-3-27b-it131K$0.08$0.16
deepinfra/google/gemma-3-4b-it131K$0.05$0.10
deepinfra/google/gemma-4-26B-A4B-it262K$0.07$0.34
deepinfra/google/gemma-4-31B-it262K$0.20$0.40
deepinfra/meta-llama/Llama-3.3-70B-Instruct-Turbo131K$0.10$0.32
deepinfra/meta-llama/Llama-4-Scout-17B-16E-Instruct328K$0.10$0.30
deepinfra/MiniMaxAI/MiniMax-M3524K$0.28$1
deepinfra/mistralai/Mistral-Small-24B-Instruct-250133K$0.05$0.08
deepinfra/moonshotai/Kimi-K2.6262K$0.75$4
deepinfra/moonshotai/Kimi-K31.0M$3$14
deepinfra/openai/gpt-oss-120b131K$0.04$0.17
deepinfra/openai/gpt-oss-20b131K$0.03$0.14
deepinfra/Qwen/Qwen3-235B-A22B-Instruct-2507262K$0.09$0.55
deepinfra/Qwen/Qwen3-30B-A3B41K$0.12$0.50
deepinfra/Qwen/Qwen3-32B41K$0.08$0.28
deepinfra/Qwen/Qwen3-Coder-480B-A35B-Instruct-Turbo262K$0.30$1
deepinfra/Qwen/Qwen3-Next-80B-A3B-Instruct262K$0.09$1
deepinfra/Qwen/Qwen3-VL-235B-A22B-Instruct262K$0.20$0.88
deepinfra/Qwen/Qwen3-VL-30B-A3B-Instruct262K$0.15$0.60
deepinfra/Qwen/Qwen3.5-27B262K$0.26$3
deepinfra/Qwen/Qwen3.5-35B-A3B262K$0.14$1
deepinfra/Qwen/Qwen3.5-397B-A17B262K$0.45$3
deepinfra/Qwen/Qwen3.5-9B262K$0.10$0.15
deepinfra/Qwen/Qwen3.6-27B262K$0.32$3
deepinfra/Qwen/Qwen3.6-35B-A3B262K$0.10$0.95
deepinfra/Qwen/Qwen3.7-Max256K$3$8
deepinfra/Qwen/Qwen3.8-27B262K$0.20$3
deepinfra/Qwen/Qwen3.8-Flash1.0M$0.11$0.38
deepinfra/Qwen/Qwen3.8-Max256K$2$5
deepinfra/stepfun-ai/Step-5-Preview1.0M$1$3
deepinfra/tencent/Hy4-preview1.0M$0.83$3
deepinfra/thinkingmachines/Inkling524K$0.95$4
deepinfra/thinkingmachines/Inkling-Small524K$0.45$1
deepinfra/XiaomiMiMo/MiMo-V2.6-Flash1.0M$0.14$0.28
deepinfra/XiaomiMiMo/MiMo-V2.6-Pro1.0M$0.43$0.87
deepinfra/zai-org/GLM-4.6203K$0.50$2
deepinfra/zai-org/GLM-4.7203K$0.40$2
deepinfra/zai-org/GLM-5.21.0M$0.75$2
deepinfra/zai-org/GLM-5.31.0M$0.90$4
deepinfra/zai-org/GLM-5.3-Flash1.0M$0.15$0.50
56 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: {
id: "deepinfra/ByteDance/Seed-2.0-code",
apiKey: process.env.DEEPINFRA_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
? "deepinfra/zai-org/GLM-5.3-Flash"
: "deepinfra/ByteDance/Seed-2.0-code";
}
});