Integration guides
OpenCode
An AI coding agent in your terminal, working with any OpenAI-compatible service; config and key live in separate files, so the key never slips into version control.
- 01
Install and verify
Install with the official script or globally via npm, then print the version to confirm. On Windows, OpenCode runs best under WSL, where its config follows the Linux paths inside WSL.
# Official script (macOS / Linux / WSL) curl -fsSL https://opencode.ai/install | bash # Or via npm (all platforms) npm install -g opencode-ai # Verify opencode --version - 02
Find the config files
OpenCode keeps 'provider definitions' and 'keys' separate: opencode.json holds provider definitions (supports .jsonc with comments), while keys live in auth.json. Below are the opencode.json locations; you can also place one in a project root to apply only there.
- Windows
%USERPROFILE%\.config\opencode\opencode.json- macOS / Linux
~/.config/opencode/opencode.json- Project-level
<project-root>/opencode.json
- 03
Define the provider
Add a provider in opencode.json (note it's singular provider, not providers). Use the @ai-sdk/openai-compatible adapter; baseURL follows the OpenAI-compatible format and must include /v1; list the model ids you want under models. Don't put the key here.
{ "$schema": "https://opencode.ai/config.json", "provider": { "xylemnode": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "https://api.xylemnode.com/v1" }, "models": { "gpt-5.6-sol": {} } } } } - 04
Add the key
Put the key in a separate auth.json, using the same key name as the provider above. The easiest way is to run opencode auth login and let it write the entry; you can also edit it by hand (on macOS/Linux at ~/.local/share/opencode/auth.json).
{ "xylemnode": { "type": "api", "key": "sk-your-key" } } - 05
Pick a model and test
Restart OpenCode, use /models to see what's available, switch to a XylemNode model with /model, and send a message to confirm.
/models /model xylemnode/gpt-5.6-sol
Common pitfalls
1) Use provider (singular) as the key — providers will error. 2) baseURL must end in /v1. 3) If a model isn't in /models, the id usually doesn't match the server, or you didn't restart. 4) If it can't find the npm package, run npm install once in ~/.config/opencode/.
Common questions
The provider is configured in OpenCode but its models never appear, or you get ProviderModelNotFoundError
Usually the provider block has npm but no models. There is a confirmed behaviour in the repository: a provider-level npm field is silently ignored unless models is configured as well — nothing errors, the provider simply does not take effect. So list the model ids you intend to use under models. And remember both files are needed: the provider definition lives in opencode.json, the key on its own in auth.json; one without the other will not work.