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

SiliconFlow logoSiliconFlow

Access 57 SiliconFlow models through Mastra's model router. Authentication is handled automatically using the SILICONFLOW_API_KEY environment variable.

Learn more in the SiliconFlow documentation.

.env
SILICONFLOW_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: "siliconflow/ByteDance-Seed/Seed-OSS-36B-Instruct"
});

// 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 SiliconFlow documentation for details.

Models
Models的直接链接

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
siliconflow/ByteDance-Seed/Seed-OSS-36B-Instruct262K$0.21$0.57
siliconflow/deepseek-ai/DeepSeek-R1164K$0.50$2
siliconflow/deepseek-ai/DeepSeek-V3164K$0.25$1
siliconflow/deepseek-ai/DeepSeek-V3.1164K$0.27$1
siliconflow/deepseek-ai/DeepSeek-V3.1-Terminus164K$0.27$1
siliconflow/deepseek-ai/DeepSeek-V3.2164K$0.27$0.42
siliconflow/deepseek-ai/DeepSeek-V3.2-Exp164K$0.27$0.41
siliconflow/deepseek-ai/DeepSeek-V4-Flash1.0M$0.13$0.28
siliconflow/deepseek-ai/DeepSeek-V4-Flash-07311.0M$0.22$0.66
siliconflow/deepseek-ai/DeepSeek-V4-Flash-Vision-Exp1.0M$0.44$1
siliconflow/deepseek-ai/DeepSeek-V4-Pro1.0M$2$3
siliconflow/deepseek-ai/DeepSeek-V4-Pro-08131.0M$1$4
siliconflow/google/gemma-4-12B-it262K$0.10$0.30
siliconflow/google/gemma-4-26B-A4B-it262K$0.12$0.40
siliconflow/google/gemma-4-31B-it262K$0.13$0.40
siliconflow/inclusionAI/Ling-flash-2.0131K$0.14$0.57
siliconflow/meituan-longcat/LongCat-2.01.0M$0.75$3
siliconflow/MiniMaxAI/MiniMax-M2.5197K$0.30$1
siliconflow/MiniMaxAI/MiniMax-M31.0M$0.30$1
siliconflow/moonshotai/Kimi-K2.5262K$0.45$2
siliconflow/moonshotai/Kimi-K2.6262K$0.77$3
siliconflow/moonshotai/Kimi-K2.7-Code262K$0.86$4
siliconflow/moonshotai/Kimi-K31.0M$3$14
siliconflow/nex-agi/Nex-N2-Pro262K$0.50$3
siliconflow/openai/gpt-oss-120b131K$0.05$0.45
siliconflow/openai/gpt-oss-20b131K$0.04$0.18
siliconflow/Qwen/Qwen2.5-72B-Instruct33K$0.59$0.59
siliconflow/Qwen/Qwen2.5-7B-Instruct33K$0.05$0.05
siliconflow/Qwen/Qwen3-14B131K$0.07$0.28
siliconflow/Qwen/Qwen3-30B-A3B-Instruct-2507262K$0.09$0.30
siliconflow/Qwen/Qwen3-32B131K$0.14$0.57
siliconflow/Qwen/Qwen3-8B131K$0.06$0.06
siliconflow/Qwen/Qwen3-Coder-30B-A3B-Instruct262K$0.07$0.28
siliconflow/Qwen/Qwen3-Coder-480B-A35B-Instruct262K$0.25$1
siliconflow/Qwen/Qwen3-VL-30B-A3B-Instruct262K$0.29$1
siliconflow/Qwen/Qwen3-VL-30B-A3B-Thinking262K$0.29$1
siliconflow/Qwen/Qwen3-VL-32B-Instruct262K$0.20$0.60
siliconflow/Qwen/Qwen3-VL-32B-Thinking262K$0.20$2
siliconflow/Qwen/Qwen3-VL-8B-Instruct262K$0.18$0.68
siliconflow/Qwen/Qwen3.5-122B-A10B262K$0.26$2
siliconflow/Qwen/Qwen3.5-27B262K$0.25$2
siliconflow/Qwen/Qwen3.5-35B-A3B262K$0.24$2
siliconflow/Qwen/Qwen3.5-397B-A17B262K$0.39$2
siliconflow/Qwen/Qwen3.5-9B262K$0.10$0.15
siliconflow/Qwen/Qwen3.6-27B262K$0.30$3
siliconflow/Qwen/Qwen3.6-35B-A3B262K$0.20$2
siliconflow/Qwen/Qwen3.8-2.4T-A95B1.0M$2$6
siliconflow/stepfun-ai/Step-3.5-Flash262K$0.10$0.30
siliconflow/tencent/Hunyuan-A13B-Instruct131K$0.14$0.57
siliconflow/tencent/Hy3262K$0.13$0.53
siliconflow/zai-org/GLM-4.5-Air131K$0.14$0.86
siliconflow/zai-org/GLM-5205K$0.95$3
siliconflow/zai-org/GLM-5.1205K$1$4
siliconflow/zai-org/GLM-5.21.0M$1$4
siliconflow/zai-org/GLM-5.31.0M$1$4
siliconflow/zai-org/GLM-5.3-Flash1.0M$0.15$0.50
siliconflow/zai-org/GLM-5V-Turbo200K$1$4
57 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.siliconflow.com/v1",
id: "siliconflow/ByteDance-Seed/Seed-OSS-36B-Instruct",
apiKey: process.env.SILICONFLOW_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
? "siliconflow/zai-org/GLM-5V-Turbo"
: "siliconflow/ByteDance-Seed/Seed-OSS-36B-Instruct";
}
});