Loading
Skip to content
RedRouterRedRouter
Dashboard ↗

OpenCode

Add RedRouter as a custom OpenAI-compatible provider in OpenCode. This recipe targets the provider / npm configuration documented for OpenCode 1.x; it is not a live-tested result. The security-agent checks record a specific previously tested version.

Install and configure

npm install -g opencode-ai
export REDROUTER_API_KEY="your-redrouter-api-key"

Save opencode.json in your project:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "redrouter/red-cyber-1",
  "permission": "ask",
  "provider": {
    "redrouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "RedRouter",
      "options": {
        "baseURL": "https://redrouter.org/v1",
        "apiKey": "{env:REDROUTER_API_KEY}"
      },
      "models": {
        "red-cyber-1": {
          "name": "Red Cyber 1",
          "tool_call": true,
          "reasoning": false,
          "modalities": {"input": ["text"], "output": ["text"]},
          "limit": {"context": 1048576, "output": 8192}
        }
      }
    }
  }
}

redrouter/ identifies your local provider configuration; the model sent to RedRouter is red-cyber-1. Keep the environment placeholder in the file so the key is not committed.

opencode

Choose redrouter/red-cyber-1 if it is not already selected, then ask it to summarize the README. A successful setup returns a text answer and can request local tools subject to your permissions.

Configure capabilities deliberately

The catalog values above describe the current model: text-only, tool calling, a 1,048,576-token context, and an 8,192-token output maximum. Check Models when changing models or updating these values. An advertised context window does not override request-body limits or leave the entire window available after reserving output.

reasoning: false avoids advertising a client reasoning control that RedRouter does not implement. It does not promise that the model produces no internal reasoning or that all output is visible text. See reasoning.

Use @ai-sdk/openai-compatible for this Chat Completions recipe. Choosing another package can change the endpoint and payload. OpenCode's newer configuration schemas may differ; follow the provider documentation for your installed major version rather than mixing keys from separate versions.

Troubleshoot the first turn

If the provider or model is missing, check the project config path and exact model reference. If authentication fails, verify the environment in the shell that launched OpenCode. If a later tool turn fails, inspect the error and output truncation rather than changing the model blindly; see tool calling and troubleshooting.

References: OpenCode provider configuration, CLI, and permissions.

↑ ↓ to select · Enter to open · Esc to close