Documentation
OpenCode in the NexoRouter documentation.
OpenCode
Status: Candidate setup, not yet verified by NexoRouter.
OpenCode supports custom OpenAI-compatible providers. Configure NexoRouter as a provider that calls https://api.nexorouter.com/v1 and sends Chat Completions requests.
What this setup uses
| Item | Value |
|---|---|
| Provider type | Custom OpenAI-compatible provider |
| Base URL | https://api.nexorouter.com/v1 |
| API key | NexoRouter API key |
| Model ID | Exact ID copied from Models |
| Stable public endpoint | POST /v1/chat/completions |
Do not use this page to configure Codex CLI, Claude Code, or Gemini-native clients. Those tools have separate protocol requirements.
Before you start
- Install OpenCode from the current OpenCode install docs.
- Run
opencode --versionto confirm it is available. - Create a NexoRouter API key with a low budget for the first test.
- Copy one model ID from Models, for example
deepseek-v4-flash. - Keep the key out of
opencode.json, Git, screenshots, and support messages.
OpenCode references:
Credential flow
OpenCode's provider docs use the /connect command to add provider credentials. If your version supports it:
/connect
Then choose Other, enter a provider ID such as nexorouter, and paste your NexoRouter API key.
If your OpenCode version uses a different credential flow, follow that version's provider docs. The important part is that the secret is stored in OpenCode's credential storage, not committed in project config.
Provider configuration
Use a stable provider ID such as nexorouter.
Global config is commonly stored at:
~/.config/opencode/opencode.json
Example:
{
"provider": {
"nexorouter": {
"npm": "@ai-sdk/openai-compatible",
"name": "NexoRouter",
"options": {
"baseURL": "https://api.nexorouter.com/v1"
},
"models": {
"deepseek-v4-flash": {
"name": "DeepSeek V4 Flash"
},
"gpt-4o-mini": {
"name": "GPT-4o mini"
},
"Qwen/Qwen-Plus": {
"name": "Qwen Plus"
}
}
}
},
"model": "nexorouter/deepseek-v4-flash"
}
If your OpenCode version requires the key in config, prefer an environment variable reference if supported by that version. Do not hard-code the full key in a repository file.
First test
Start with a read-only task:
Read the current directory and summarize the project in one paragraph. Do not edit files.
Then open Usage Logs and confirm:
- API key name.
- Model ID.
- Request status.
- Prompt and completion tokens.
- Cost and latency.
- Request ID.
Second test
Only after the read-only task appears in Usage Logs, test one small edit in a disposable branch:
Create a short README note in a temporary branch. Do not change existing source files.
If the text prompt works but the edit workflow fails, treat that model/tool pair as not ready for real coding-agent work.
Common issues
| Symptom | Check |
|---|---|
invalid_api_key | Confirm the credential is attached to the nexorouter provider and the base URL is https://api.nexorouter.com/v1. |
model_not_found | Copy the exact model ID from Models and make sure the OpenCode model key matches it. |
| Text works but edits fail | Test another model and review Tool calling. |
| Request does not appear in Usage Logs | Confirm OpenCode is using the nexorouter provider, not a built-in provider. |
| Provider package or cache errors | Follow OpenCode's troubleshooting docs for the current version. |
Known limits
- Treat this page as a candidate setup until your current OpenCode version passes the read-only test, edit test, and Usage Logs check.
- Streaming and tool calling behavior can vary by model and OpenCode version.
- Use a low-budget key for local agents.
- Do not reuse a personal production key in shared repositories or demos.