Skip to content

DocsCoding agents

opencode

Use opencode, the open source terminal coding agent, with your Osarai GPU through an OpenAI-compatible provider.

opencode is an open source coding agent with a terminal interface. It talks to Osarai through its OpenAI-compatible provider.

opencode answering on qwen3.8-27b served by Osarai
opencode running on an Osarai instance.

Install

Terminal
npm install -g opencode-ai

Configure

Create opencode.json in your project (it applies to that project) or ~/.config/opencode/opencode.json (it applies everywhere):

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "osarai": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Osarai",
      "options": {
        "baseURL": "https://osarai.xyz/v1",
        "apiKey": "{env:OSARAI_API_KEY}"
      },
      "models": {
        "qwen3.8-27b": {
          "name": "Qwen3.8 27B",
          "tool_call": true,
          "reasoning": true,
          "limit": { "context": 131072, "output": 16384 }
        }
      }
    }
  },
  "model": "osarai/qwen3.8-27b"
}
  • {env:OSARAI_API_KEY} reads the key from your environment, so the file holds no secret.
  • limit.context tells opencode when to compact; set it to your instance's context window.
  • To add another model you run (for example gpt-oss-20b), add another entry under models.

Run

Terminal
export OSARAI_API_KEY="qck_your_key_here"
cd your-project
opencode

Type a request, or switch models with /models. To run one prompt without the interface:

Terminal
opencode run "Explain what src/math.ts does"

Troubleshooting

SymptomFix
Model not found: osarai/qwen3.8-27bThe key under models must match the part after osarai/ in model
401OSARAI_API_KEY is not set in the shell that started opencode
503 … not ready yetThe instance is still starting; wait for Ready on the instance page
The model never calls toolsUse a model with tool calls (qwen3.8-27b) and keep "tool_call": true