1. Choose a configuration location
The simplest option is to createopencode.jsonc in your project’s root directory. JSONC supports comments, making the file easier to maintain.
The default global configuration is ~/.config/opencode/opencode.jsonc. On Windows, ~ refers to your user home directory. If you use a custom configuration directory, check the location the client actually loads; do not assume it is under %APPDATA%.
Run opencode --version first. Newer versions use providers / package / settings; older versions use provider / npm / options. Do not mix the two formats.
2. Set the API key environment variable
- Windows PowerShell
- macOS / Linux
3. Configure the provider
- V2
- V1 (legacy)
opencode.jsonc
{env:VIVI_API_KEY} reads the environment variable available to the process that launches OpenCode. To use Gemini or an OpenAI-compatible protocol, change the provider adapter, URL, and model list together. Replacing only the model name in the Anthropic example is not enough.4. Restart and select a model
- Close the old session. If you saved user-level environment variables, open a new terminal. If you set them only in the current terminal, launch from that terminal.
- Run
opencodein your project directory. - Enter
/modelsand search forviviapiorViVi-API. - Select the model and send a short test message.