Configure OpenCode with XSI Router (Responses-first + Chat)

Posted January 10, 2026 by The XAI Tech Teamย โ€ย 2ย min read

opencode

OpenCode (opencode) can be routed through XSI Router with one unified endpoint. For gpt-6-astra, OpenCode's built-in openai provider sends Responses requests that XSI Router forwards to the official OpenAI API. Regular OpenAI-compatible models continue to use the standard compatibility API. This guide keeps only two clear production-ready profiles:

  1. gpt-6-astra (Responses API)
  2. MiniMax-M2.5 (Chat API)

Prerequisites

  1. You already created an API key at m.xsirouter.com.
  2. opencode is installed locally.

Config file location

  1. Linux/macOS: ~/.config/opencode/opencode.jsonc
  2. Windows: %USERPROFILE%\.config\opencode\opencode.jsonc

Keep only one profile at a time. To switch profiles, overwrite opencode.jsonc.


Important notes

  1. This guide uses OpenCode's openai provider and points baseURL to https://api.xsirouter.com/v1.
  2. gpt-6-astra uses the OpenAI Responses API and needs no extra request headers.
  3. If you enable OpenCode's built-in Codex OAuth plugin, it connects directly to chatgpt.com/backend-api/codex/responses by default and does not go through XSI Router. If you want traffic to go through XSI Router, use the openai provider config in this guide.

Profile A: gpt-6-astra (Responses-first path)

Linux/macOS

export XAI_API_KEY="sk-xxx"
mkdir -p ~/.config/opencode
cat > ~/.config/opencode/opencode.jsonc << 'JSON'
{
  "$schema": "https://opencode.ai/config.json",
  "model": "openai/gpt-6-astra",
  "small_model": "openai/gpt-6-astra",
  "provider": {
    "openai": {
      "options": {
        "baseURL": "https://api.xsirouter.com/v1",
        "apiKey": "{env:XAI_API_KEY}"
      },
      "models": {
        "gpt-6-astra": {}
      }
    }
  }
}
JSON

opencode debug config
opencode run "hello"

Windows (PowerShell)

$env:XAI_API_KEY="sk-xxx"
New-Item -ItemType Directory -Path "$env:USERPROFILE\.config\opencode" -Force | Out-Null
@'
{
  "$schema": "https://opencode.ai/config.json",
  "model": "openai/gpt-6-astra",
  "small_model": "openai/gpt-6-astra",
  "provider": {
    "openai": {
      "options": {
        "baseURL": "https://api.xsirouter.com/v1",
        "apiKey": "{env:XAI_API_KEY}"
      },
      "models": {
        "gpt-6-astra": {}
      }
    }
  }
}
'@ | Set-Content -Path "$env:USERPROFILE\.config\opencode\opencode.jsonc" -Encoding utf8

opencode debug config
opencode run "hello"

Profile B: MiniMax-M2.5 (Chat API)

Linux/macOS

export XAI_API_KEY="sk-xxx"
mkdir -p ~/.config/opencode
cat > ~/.config/opencode/opencode.jsonc << 'JSON'
{
  "$schema": "https://opencode.ai/config.json",
  "model": "xai-chat/MiniMax-M2.5",
  "small_model": "xai-chat/MiniMax-M2.5",
  "provider": {
    "xai-chat": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://api.xsirouter.com/v1",
        "apiKey": "{env:XAI_API_KEY}"
      },
      "models": {
        "MiniMax-M2.5": {}
      }
    }
  }
}
JSON

opencode debug config
opencode run "hello"

Windows (PowerShell)

$env:XAI_API_KEY="sk-xxx"
New-Item -ItemType Directory -Path "$env:USERPROFILE\.config\opencode" -Force | Out-Null
@'
{
  "$schema": "https://opencode.ai/config.json",
  "model": "xai-chat/MiniMax-M2.5",
  "small_model": "xai-chat/MiniMax-M2.5",
  "provider": {
    "xai-chat": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://api.xsirouter.com/v1",
        "apiKey": "{env:XAI_API_KEY}"
      },
      "models": {
        "MiniMax-M2.5": {}
      }
    }
  }
}
'@ | Set-Content -Path "$env:USERPROFILE\.config\opencode\opencode.jsonc" -Encoding utf8

opencode debug config
opencode run "hello"

Which profile should I use?

  1. If you want gpt-6-astra, use Profile A.
  2. If you want MiniMax-M2.5, use Profile B.
  3. Do not mix both profiles in the same opencode.jsonc.