Configure in OpenCode
OpenCode is both a CLI + TUI AI programming agent tool that runs in the terminal, and also provides IDE plugin integration. It can complete fast code generation, debugging, project analysis, file operations, and cross-project collaboration in different development environments.
Install OpenCodecurl -fsSL https://opencode.ai/install | bash
OriginRouter supports calling models in OpenCode via the Anthropic Protocol.
Although OriginRouter converts model protocols so that you can access multiple models on one platform, we still recommend that you use the native protocol to access models from their respective providers. For example:
- Use Anthropic Protocol to access Claude series models
- Use OpenAI Protocol to access GPT series models
This way you can get the best compatibility and complete functional experience.
Run the following command to start the login process:
opencode auth login
In the popup options, search for and select the Other category
Enter a supplier ID (custom name, can only use lowercase letters and numbers), for example
originrouterEnter the API Key you applied for in the Developer Console
Open the configuration file ~/.config/opencode/opencode.json and edit according to the following template:
Depending on your subscription plan, copy the matching template below verbatim:
opencode.json
For users on the pay-as-you-go API plan. Requests are served via the /beta endpoint and billed per request.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"originrouter": {
"npm": "@ai-sdk/anthropic",
"name": "OriginRouter",
"options": {
"baseURL": "https://api.easytransnote.com/beta"
},
"models": {
"claude-sonnet-4-6": {
"name": "Claude Sonnet 4.6"
},
"gpt-5.4": {
"name": "GPT 5.4"
},
"gemini-3.1-pro-preview": {
"name": "Gemini 3.1 Pro"
}
}
}
}
}
With an OriginRouter One subscription, choose the corresponding Coding API endpoint and make sure the model ID comes from the Supported Models list; with the pay-as-you-go API plan, choose the corresponding Beta API endpoint and make sure the model ID comes from the Model List; a plan and endpoint mismatch may make models unavailable or result in unexpected billing.
After configuration is complete, open a new terminal and run the following command to test:
opencode