Skip to main content

Documentation Index

Fetch the complete documentation index at:
https://docs.llmrouter.app/llms.txt
Use this file to discover all available models, tags, and features before exploring further.

OpenCode Integration

OpenCode is a fast and intuitive terminal-based AI coding assistant. It helps developers generate code, debug, refactor, explain code, and build features directly from the command line. By connecting OpenCode to LLM Router, you can access top models from Anthropic, OpenAI, Google, xAI, and others through a single unified endpoint while gaining intelligent routing, Skills, context optimization, and privacy features.

Configuring OpenCode with LLM Router

1. Start OpenCode

Open your terminal and run:
opencode

2. Connect to LLM Router

In the OpenCode interface, run the connect command:
/connect
  • Select OpenAI Compatible (or Custom Provider)
  • Base URL: https://api.llmrouter.app/v1
  • API Key: Paste your LLM Router API key (sk_llmr_...)

3. Select a Model

Run the following command to choose a model:
/models
You can select any model available through LLM Router, such as:
  • anthropic/claude-opus-4.6
  • anthropic/claude-sonnet-4.6
  • openai/gpt-5.4
  • google/gemini-3.1-pro
  • xai/grok-4.20
For the best experience, set up your routing preferences in the LLM Router Dashboard:
  • Assign tags like coding, testing, ui design, refactoring, etc.
  • Enable relevant Skills
  • Turn on Zero Data Retention (ZDR) for sensitive projects
  • Configure default model preferences and optimization settings
These settings will automatically apply to all requests made from OpenCode.

5. (Optional) Advanced Configuration

You can create a configuration file named opencode.json for more control:
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "custom": {
      "baseUrl": "https://api.llmrouter.app/v1",
      "apiKey": "sk_llmr_your_key_here",
      "model": "anthropic/claude-opus-4.6"
    }
  }
}

Start Using OpenCode

Once connected, you can start coding with natural language prompts:
opencode "Create a full-stack todo app with Next.js 15 and Supabase"
or
opencode "Refactor this authentication logic to use JWT with refresh tokens"
All your requests will be intelligently routed and optimized by LLM Router.

Benefits

  • Access to the best models with automatic routing
  • Automatic relevant Skill injection
  • Zero Data Retention for private codebases
  • Reduced costs through context optimization