LiteRouter Docs

OpenCode

Point the OpenCode terminal agent at LiteRouter as a custom provider.

OpenCode talks to any OpenAI-compatible API through the @ai-sdk/openai-compatible adapter. Add LiteRouter as a provider in your OpenCode config.

Configure

Add a provider to ~/.config/opencode/opencode.json:

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "literouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LiteRouter",
      "options": {
        "baseURL": "https://api.literouter.com/v1",
        "apiKey": "{env:LITEROUTER_API_KEY}"
      },
      "models": {
        "glm-5.2": { "name": "GLM 5.2" }
      }
    }
  }
}

Export your key, then run OpenCode and pick the model with /models:

bash
export LITEROUTER_API_KEY="your_literouter_api_key"
opencode
💡

Add more entries under models for any IDs from the Models section.