Configure OpenCode with XSI Router (Responses-first + Chat)
Posted January 10, 2026 by The XAI Tech Teamย โย 2ย min read
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:
gpt-6-astra(Responses API)MiniMax-M2.5(Chat API)
Prerequisites
- You already created an API key at m.xsirouter.com.
opencodeis installed locally.
Config file location
- Linux/macOS:
~/.config/opencode/opencode.jsonc - Windows:
%USERPROFILE%\.config\opencode\opencode.jsonc
Keep only one profile at a time. To switch profiles, overwrite opencode.jsonc.
Important notes
- This guide uses OpenCode's
openaiprovider and pointsbaseURLtohttps://api.xsirouter.com/v1. gpt-6-astrauses the OpenAI Responses API and needs no extra request headers.- If you enable OpenCode's built-in Codex OAuth plugin, it connects directly to
chatgpt.com/backend-api/codex/responsesby default and does not go through XSI Router. If you want traffic to go through XSI Router, use theopenaiprovider 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?
- If you want
gpt-6-astra, use Profile A. - If you want
MiniMax-M2.5, use Profile B. - Do not mix both profiles in the same
opencode.jsonc.