GitHub Copilot
Access 17 GitHub Copilot models through Mastra’s model router. Authentication is handled automatically using the GITHUB_TOKEN
environment variable.
Learn more in the GitHub Copilot documentation .
GITHUB_TOKEN=your-api-key
import { Agent } from "@mastra/core";
const agent = new Agent({
name: "my-agent",
instructions: "You are a helpful assistant",
model: "github-copilot/claude-3.5-sonnet"
});
// 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 GitHub Copilot documentation for details.
Models
Model | Context | Tools | Reasoning | Image | Audio | Video | Input $/1M | Output $/1M |
---|---|---|---|---|---|---|---|---|
github-copilot/gemini-2.0-flash-001 | 1.0M | — | — | |||||
github-copilot/claude-opus-4 | 80K | — | — | |||||
github-copilot/grok-code-fast-1 | 256K | — | — | |||||
github-copilot/claude-3.5-sonnet | 90K | — | — | |||||
github-copilot/o3-mini | 128K | — | — | |||||
github-copilot/gpt-5-codex | 128K | — | — | |||||
github-copilot/gpt-4o | 128K | — | — | |||||
github-copilot/gpt-4.1 | 128K | — | — | |||||
github-copilot/o4-mini | 128K | — | — | |||||
github-copilot/claude-opus-41 | 80K | — | — | |||||
github-copilot/gpt-5-mini | 128K | — | — | |||||
github-copilot/claude-3.7-sonnet | 200K | — | — | |||||
github-copilot/gemini-2.5-pro | 128K | — | — | |||||
github-copilot/o3 | 128K | — | — | |||||
github-copilot/claude-sonnet-4 | 128K | — | — | |||||
github-copilot/gpt-5 | 128K | — | — | |||||
github-copilot/claude-3.7-sonnet-thought | 200K | — | — | |||||
github-copilot/claude-sonnet-4.5 | 128K | — | — |
Advanced Configuration
Custom Headers
const agent = new Agent({
name: "custom-agent",
model: {
url: "https://api.githubcopilot.com/chat/completions",
modelId: "claude-3.5-sonnet",
apiKey: process.env.GITHUB_TOKEN,
headers: {
"X-Custom-Header": "value"
}
}
});
Dynamic Model Selection
const agent = new Agent({
name: "dynamic-agent",
model: ({ runtimeContext }) => {
const useAdvanced = runtimeContext.task === "complex";
return useAdvanced
? "github-copilot/claude-3.5-sonnet"
: "github-copilot/claude-3.7-sonnet";
}
});