GitHub Models
透過 Mastra 的模型路由器存取 55 個 GitHub Models 模型。系統會自動使用 GITHUB_TOKEN 環境變數進行驗證。
詳情請參閱GitHub Models 文件。
.env
GITHUB_TOKEN=your-api-token
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: 'github-models/ai21-labs/ai21-jamba-1.5-large',
})
// 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 端點。部分 Provider 專屬功能可能無法使用,詳情請參閱GitHub Models 文件。
模型模型 的直接連結
| Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
|---|---|---|---|---|---|---|---|---|
github-models/ai21-labs/ai21-jamba-1.5-large | 256K | — | — | |||||
github-models/ai21-labs/ai21-jamba-1.5-mini | 256K | — | — | |||||
github-models/cohere/cohere-command-a | 128K | — | — | |||||
github-models/cohere/cohere-command-r | 128K | — | — | |||||
github-models/cohere/cohere-command-r-08-2024 | 128K | — | — | |||||
github-models/cohere/cohere-command-r-plus | 128K | — | — | |||||
github-models/cohere/cohere-command-r-plus-08-2024 | 128K | — | — | |||||
github-models/core42/jais-30b-chat | 8K | — | — | |||||
github-models/deepseek/deepseek-r1 | 66K | — | — | |||||
github-models/deepseek/deepseek-r1-0528 | 66K | — | — | |||||
github-models/deepseek/deepseek-v3-0324 | 128K | — | — | |||||
github-models/meta/llama-3.2-11b-vision-instruct | 128K | — | — | |||||
github-models/meta/llama-3.2-90b-vision-instruct | 128K | — | — | |||||
github-models/meta/llama-3.3-70b-instruct | 128K | — | — | |||||
github-models/meta/llama-4-maverick-17b-128e-instruct-fp8 | 128K | — | — | |||||
github-models/meta/llama-4-scout-17b-16e-instruct | 128K | — | — | |||||
github-models/meta/meta-llama-3-70b-instruct | 8K | — | — | |||||
github-models/meta/meta-llama-3-8b-instruct | 8K | — | — | |||||
github-models/meta/meta-llama-3.1-405b-instruct | 128K | — | — | |||||
github-models/meta/meta-llama-3.1-70b-instruct | 128K | — | — | |||||
github-models/meta/meta-llama-3.1-8b-instruct | 128K | — | — | |||||
github-models/microsoft/mai-ds-r1 | 66K | — | — | |||||
github-models/microsoft/phi-3-medium-128k-instruct | 128K | — | — | |||||
github-models/microsoft/phi-3-medium-4k-instruct | 4K | — | — | |||||
github-models/microsoft/phi-3-mini-128k-instruct | 128K | — | — | |||||
github-models/microsoft/phi-3-mini-4k-instruct | 4K | — | — | |||||
github-models/microsoft/phi-3-small-128k-instruct | 128K | — | — | |||||
github-models/microsoft/phi-3-small-8k-instruct | 8K | — | — | |||||
github-models/microsoft/phi-3.5-mini-instruct | 128K | — | — | |||||
github-models/microsoft/phi-3.5-moe-instruct | 128K | — | — | |||||
github-models/microsoft/phi-3.5-vision-instruct | 128K | — | — | |||||
github-models/microsoft/phi-4 | 16K | — | — | |||||
github-models/microsoft/phi-4-mini-instruct | 128K | — | — | |||||
github-models/microsoft/phi-4-mini-reasoning | 128K | — | — | |||||
github-models/microsoft/phi-4-multimodal-instruct | 128K | — | — | |||||
github-models/microsoft/phi-4-reasoning | 128K | — | — | |||||
github-models/mistral-ai/codestral-2501 | 32K | — | — | |||||
github-models/mistral-ai/ministral-3b | 128K | — | — | |||||
github-models/mistral-ai/mistral-large-2411 | 128K | — | — | |||||
github-models/mistral-ai/mistral-medium-2505 | 128K | — | — | |||||
github-models/mistral-ai/mistral-nemo | 128K | — | — | |||||
github-models/mistral-ai/mistral-small-2503 | 128K | — | — | |||||
github-models/openai/gpt-4.1 | 128K | — | — | |||||
github-models/openai/gpt-4.1-mini | 128K | — | — | |||||
github-models/openai/gpt-4.1-nano | 128K | — | — | |||||
github-models/openai/gpt-4o | 128K | — | — | |||||
github-models/openai/gpt-4o-mini | 128K | — | — | |||||
github-models/openai/o1 | 200K | — | — | |||||
github-models/openai/o1-mini | 128K | — | — | |||||
github-models/openai/o1-preview | 128K | — | — | |||||
github-models/openai/o3 | 200K | — | — | |||||
github-models/openai/o3-mini | 200K | — | — | |||||
github-models/openai/o4-mini | 200K | — | — | |||||
github-models/xai/grok-3 | 128K | — | — | |||||
github-models/xai/grok-3-mini | 128K | — | — |
進階設定進階設定 的直接連結
自訂標頭自訂標頭 的直接連結
src/mastra/agents/my-agent.ts
const agent = new Agent({
id: 'custom-agent',
name: 'custom-agent',
model: {
url: 'https://models.github.ai/inference',
id: 'github-models/ai21-labs/ai21-jamba-1.5-large',
apiKey: process.env.GITHUB_TOKEN,
headers: {
'X-Custom-Header': 'value',
},
},
})
動態選擇模型動態選擇模型 的直接連結
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
? 'github-models/xai/grok-3-mini'
: 'github-models/ai21-labs/ai21-jamba-1.5-large'
},
})