How it works
In OpenCode, models are connected through providers defined inopencode.json. For RuAPI you need two:
Before you start
1
RuAPI API key
Sign up at www.ruapi.ai and top up your balance (how to top up). Then go to Console → API Keys and click Create API key. Keys start with
sk-.2
OpenCode installed
On macOS and Linux:Or via npm on any OS, including Windows:On Windows, the OpenCode team recommends running it under WSL.
Step 1. Store your key in an environment variable
To keep the key out of your config file, OpenCode will read it from theRUAPI_API_KEY environment variable.
- macOS / Linux
- Windows (PowerShell)
Add the line to Then open a new terminal window for the change to take effect.
~/.zshrc (or ~/.bashrc if you use bash), with your own key:Step 2. Define the providers in opencode.json
Open (or create) the global config file~/.config/opencode/opencode.json and paste:
anthropicis OpenCode’s built-in Claude provider. The config only points it at RuAPI and passes in your key, so requests use Claude’s native format, with caching.ruapiis a custom provider for all other models. To add a model, add a line to themodelsblock, e.g."kimi/kimi-k3": { "name": "Kimi K3" }. You’ll find the exact model names on the pricing page.modelsets the default model inprovider/modelformat.
If your project folder also has an
opencode.json, OpenCode merges the two files, and project settings take precedence. Don’t put the key directly in a project file — use {env:RUAPI_API_KEY} as in the example.Step 3. Start OpenCode and pick a model
Go to your project folder and start the agent:/models and pick a model — for example, anthropic/claude-sonnet-5-5 or ruapi/deepseek-flash. Then give it a task:
Which model to pick
Troubleshooting
401 / Invalid key
401 / Invalid key
- Make sure
RUAPI_API_KEYis available in the terminal where OpenCode runs: after creating the variable, open a new window. baseURLmust behttps://www.ruapi.ai/v1for both providers.
A Claude model is missing from /models
A Claude model is missing from /models
OpenCode takes the model list for the built-in
anthropic provider from its own catalog. Update OpenCode; if the model is still missing, add a models section to the anthropic block with the name you need, e.g. "claude-opus-5-5": { "name": "Claude Opus 5.5" }.Model not found (404 or 503)
Model not found (404 or 503)
The model name must match the one on RuAPI exactly — copy it from the pricing page. Pick Claude models from the
anthropic provider and all other models from ruapi.Config file error
Config file error
Make sure the JSON is valid: all quotes are double quotes, and there’s no trailing comma after the last item in a block.
400: The reasoning_content in the thinking mode must be passed back
400: The reasoning_content in the thinking mode must be passed back
This can happen with DeepSeek in reasoning mode if you switch models mid-task. In most cases RuAPI automatically fixes and retries the request. If the error persists, start a new session.
What’s next
- Claude Code and Codex — other terminal agents.
- Switching from Cursor — a comparison of coding agents and step-by-step migration.
- Models and prices — the full list of available models.