Copilot support is currently experimental.
Requirements
To use GitHub Copilot models with OpenCode, you need:Enable Copilot Chat
Copilot chat in the IDE must be enabled in your GitHub settings.
Authentication setup
Using IDE plugins or CLI tools
If you’re using VSCode, the GitHub CLI, or Neovim with Copilot plugins, make sure you authenticate the tool with your GitHub account. This creates a GitHub token at one of these locations:Using an explicit GitHub token
You can also provide a GitHub token directly:- Environment variable
- Configuration file
Set the
GITHUB_TOKEN environment variable:Available models
GitHub Copilot provides access to multiple AI models:OpenAI models
OpenAI models
- GPT-3.5 Turbo
- GPT-4
- GPT-4o
- GPT-4o Mini
- GPT-4.1
- O1
- O3 Mini
- O4 Mini
Anthropic models
Anthropic models
- Claude 3.5 Sonnet
- Claude 3.7 Sonnet
- Claude 3.7 Sonnet Thinking
- Claude Sonnet 4
Google models
Google models
- Gemini 2.0 Flash
- Gemini 2.5 Pro
Configuration
Basic configuration
To use Copilot as your default provider, ensure it’s enabled in your configuration:.opencode.json
Disabling Copilot provider
If you have Copilot configured but want to use a different provider:.opencode.json
How it works
OpenCode uses the GitHub Copilot API through the following process:Token detection
OpenCode looks for your GitHub token in standard locations:
GITHUB_TOKENenvironment variable- Configuration file (
providers.copilot.apiKey) - GitHub CLI/Copilot plugin token files
Token exchange
Your GitHub token is exchanged for a Copilot bearer token using GitHub’s token exchange endpoint:
API requests
OpenCode communicates with the Copilot API at:All requests include required headers:
Editor-Version: OpenCode/1.0Editor-Plugin-Version: OpenCode/1.0Copilot-Integration-Id: vscode-chat
Troubleshooting
Error: GitHub token not found
Error: GitHub token not found
Solution: Ensure you have authenticated with one of the supported methods:
- Run
gh auth loginif using GitHub CLI - Sign in to GitHub Copilot in VSCode
- Set the
GITHUB_TOKENenvironment variable - Add the token to your
.opencode.jsonconfiguration
Error: Failed to exchange GitHub token
Error: Failed to exchange GitHub token
Possible causes:
- Your GitHub token doesn’t have Copilot permissions
- Copilot chat is not enabled in your GitHub settings
- Your Copilot subscription is not active
Error: Authentication failed (401)
Error: Authentication failed (401)
Solution: Your bearer token may have expired. OpenCode will automatically attempt to refresh it. If the problem persists:
- Verify your GitHub token is still valid
- Try re-authenticating with your IDE or GitHub CLI
- Check that your Copilot subscription is active
Model not available
Model not available
Some models may not be available depending on your Copilot subscription tier.Solution: Try a different model from the list above, or check your Copilot subscription details.
Reasoning models
For models that support reasoning (like O1, O3, O4), you can configure the reasoning effort:.opencode.json
low- Faster responses with less reasoningmedium- Balanced reasoning and speed (default)high- More thorough reasoning, slower responses
Reasoning effort only applies to models that support it. For other models, this setting is ignored.