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

ItemValue
Provider typeCustom OpenAI-compatible provider
Base URLhttps://api.nexorouter.com/v1
API keyNexoRouter API key
Model IDExact ID copied from Models
Stable public endpointPOST /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

  1. Install OpenCode from the current OpenCode install docs.
  2. Run opencode --version to confirm it is available.
  3. Create a NexoRouter API key with a low budget for the first test.
  4. Copy one model ID from Models, for example deepseek-v4-flash.
  5. 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

SymptomCheck
invalid_api_keyConfirm the credential is attached to the nexorouter provider and the base URL is https://api.nexorouter.com/v1.
model_not_foundCopy the exact model ID from Models and make sure the OpenCode model key matches it.
Text works but edits failTest another model and review Tool calling.
Request does not appear in Usage LogsConfirm OpenCode is using the nexorouter provider, not a built-in provider.
Provider package or cache errorsFollow 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.
OpenCode — NexoRouter