> Discover all available pages from the documentation index: https://mastra.zisheng.pro/llms.txt # ![FastRouter 标志](https://models.dev/logos/fastrouter.svg)FastRouter 通过 Mastra 的模型路由器访问 47 个 FastRouter 模型。系统会自动使用 `FASTROUTER_API_KEY` 环境变量完成身份验证。 更多信息请参阅[FastRouter 文档](https://fastrouter.ai/models)。 ```bash FASTROUTER_API_KEY=your-api-key ``` ```typescript import { Agent } from '@mastra/core/agent' const agent = new Agent({ id: 'my-agent', name: 'My Agent', instructions: 'You are a helpful assistant', model: 'fastrouter/anthropic/claude-opus-4.1', }) // 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 使用兼容 OpenAI 的 `/chat/completions` endpoint。部分 Provider 特有功能可能不可用,详情请参阅[FastRouter 文档](https://fastrouter.ai/models)。 ## 模型 | Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M | | ------------------------------------------------------ | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- | | `fastrouter/anthropic/claude-opus-4.1` | 200K | | | | | | $15 | $75 | | `fastrouter/anthropic/claude-opus-4.8` | 1.0M | | | | | | $5 | $25 | | `fastrouter/anthropic/claude-sonnet-4` | 200K | | | | | | $3 | $15 | | `fastrouter/anthropic/claude-sonnet-4.6` | 1.0M | | | | | | $3 | $15 | | `fastrouter/bytedance/seedance-2` | 4K | | | | | | — | — | | `fastrouter/deepseek-ai/deepseek-r1-distill-llama-70b` | 131K | | | | | | $0.03 | $0.14 | | `fastrouter/deepseek/deepseek-v4-pro` | 1.0M | | | | | | $2 | $3 | | `fastrouter/google/gemini-2.5-flash` | 1.0M | | | | | | $0.30 | $3 | | `fastrouter/google/gemini-2.5-pro` | 1.0M | | | | | | $1 | $10 | | `fastrouter/google/gemini-3-pro-image-preview` | 66K | | | | | | $2 | $12 | | `fastrouter/google/gemini-3.1-flash-image-preview` | 66K | | | | | | $0.50 | $3 | | `fastrouter/google/gemini-3.1-pro-preview` | 1.0M | | | | | | $2 | $12 | | `fastrouter/google/gemini-3.5-flash` | 1.0M | | | | | | $2 | $9 | | `fastrouter/google/gemma-4-31b-it` | 262K | | | | | | $0.13 | $0.38 | | `fastrouter/google/imagen-4.0-fast` | 480 | | | | | | — | — | | `fastrouter/google/imagen-4.0-ultra` | 480 | | | | | | — | — | | `fastrouter/google/veo3.1` | 400K | | | | | | — | — | | `fastrouter/google/veo3.1-fast` | 400K | | | | | | — | — | | `fastrouter/google/veo3.1-lite` | 400K | | | | | | — | — | | `fastrouter/leonardo-ai/lucid-origin` | 4K | | | | | | — | — | | `fastrouter/leonardo-ai/lucid-realism` | 4K | | | | | | — | — | | `fastrouter/minimax/minimax-m2.7` | 205K | | | | | | $0.30 | $1 | | `fastrouter/minimax/minimax-m2.7-highspeed` | 205K | | | | | | $0.60 | $2 | | `fastrouter/moonshotai/kimi-k2` | 131K | | | | | | $0.55 | $2 | | `fastrouter/moonshotai/kimi-k2.6` | 262K | | | | | | $0.75 | $4 | | `fastrouter/openai/gpt-4.1` | 1.0M | | | | | | $2 | $8 | | `fastrouter/openai/gpt-5` | 400K | | | | | | $1 | $10 | | `fastrouter/openai/gpt-5-mini` | 400K | | | | | | $0.25 | $2 | | `fastrouter/openai/gpt-5-nano` | 400K | | | | | | $0.05 | $0.40 | | `fastrouter/openai/gpt-5.3-codex` | 400K | | | | | | $2 | $14 | | `fastrouter/openai/gpt-5.4-mini` | 400K | | | | | | $0.75 | $5 | | `fastrouter/openai/gpt-5.4-nano` | 400K | | | | | | $0.20 | $1 | | `fastrouter/openai/gpt-5.5` | 1.1M | | | | | | $5 | $30 | | `fastrouter/openai/gpt-5.5-pro` | 1.1M | | | | | | $30 | $180 | | `fastrouter/openai/gpt-image-2` | 128K | | | | | | — | — | | `fastrouter/openai/gpt-oss-120b` | 131K | | | | | | $0.15 | $0.60 | | `fastrouter/openai/gpt-oss-20b` | 131K | | | | | | $0.05 | $0.20 | | `fastrouter/openai/gpt-realtime-1.5` | 32K | | | | | | $4 | $16 | | `fastrouter/qwen/qwen3-coder` | 262K | | | | | | $0.30 | $1 | | `fastrouter/sarvam/sarvam-105b` | 131K | | | | | | $0.04 | $0.16 | | `fastrouter/sarvam/sarvam-30b` | 128K | | | | | | $0.02 | $0.10 | | `fastrouter/wanx/wan-v2-6` | 400K | | | | | | — | — | | `fastrouter/x-ai/grok-4` | 256K | | | | | | $3 | $15 | | `fastrouter/x-ai/grok-4.3` | 1.0M | | | | | | $1 | $3 | | `fastrouter/x-ai/grok-build-0.1` | 256K | | | | | | $1 | $2 | | `fastrouter/z-ai/glm-5` | 205K | | | | | | $0.95 | $3 | | `fastrouter/z-ai/glm-5.1` | 200K | | | | | | $1 | $4 | ## 高级配置 ### 自定义请求头 ```typescript const agent = new Agent({ id: 'custom-agent', name: 'custom-agent', model: { url: 'https://go.fastrouter.ai/api/v1', id: 'fastrouter/anthropic/claude-opus-4.1', apiKey: process.env.FASTROUTER_API_KEY, headers: { 'X-Custom-Header': 'value', }, }, }) ``` ### 动态选择模型 ```typescript const agent = new Agent({ id: 'dynamic-agent', name: 'Dynamic Agent', model: ({ requestContext }) => { const useAdvanced = requestContext.task === 'complex' return useAdvanced ? 'fastrouter/z-ai/glm-5.1' : 'fastrouter/anthropic/claude-opus-4.1' }, }) ```