> ## Documentation Index
> Fetch the complete documentation index at: https://docs.viviai.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Connect OpenCode to ViVi-API.

Have an API key from the [ViVi-API dashboard](https://api.viviai.cc/dashboard) ready, and confirm that its group supports your chosen model. Back up any existing configuration before merging the fields below.

## 1. Choose a configuration location

The simplest option is to create **`opencode.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

> [tab] Windows PowerShell
>
> ```powershell theme={null}
> $env:VIVI_API_KEY = "sk-your-api-key"
> ```

> [tab] macOS / Linux
>
> ```bash theme={null}
> export VIVI_API_KEY="sk-your-api-key"
> ```

The examples below use **Anthropic Messages with Claude models**. Replace the model IDs with Claude models your token can access.

## 3. Configure the provider

> [tab] V2
>
> ```json opencode.jsonc theme={null}
> {
>   "$schema": "https://opencode.ai/config.json",
>   "model": "viviapi/claude-sonnet-4-6",
>   "providers": {
>     "viviapi": {
>       "name": "ViVi-API",
>       "package": "@opencode/ai/providers/anthropic-compatible",
>       "settings": {
>         "baseURL": "https://api.viviai.cc/v1",
>         "apiKey": "{env:VIVI_API_KEY}"
>       },
>       "models": {
>         "claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" },
>         "claude-opus-4-6": { "name": "Claude Opus 4.6" }
>       }
>     }
>   }
> }
> ```

> [tab] V1 (legacy)
>
> ```json opencode.jsonc theme={null}
> {
>   "$schema": "https://opencode.ai/config.json",
>   "model": "viviapi/claude-sonnet-4-6",
>   "provider": {
>     "viviapi": {
>       "name": "ViVi-API",
>       "npm": "@ai-sdk/anthropic",
>       "options": {
>         "baseURL": "https://api.viviai.cc/v1",
>         "apiKey": "{env:VIVI_API_KEY}"
>       },
>       "models": {
>         "claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" },
>         "claude-opus-4-6": { "name": "Claude Opus 4.6" }
>       }
>     }
>   }
> }
> ```

> [!NOTE]
>
> `{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

1. 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.
2. Run `opencode` in your project directory.
3. Enter `/models` and search for `viviapi` or `ViVi-API`.
4. Select the model and send a short test message.

For version-specific changes, see the [OpenCode configuration docs](https://opencode.ai/docs/config/) and [provider docs](https://opencode.ai/docs/providers/).

See the [Integration overview](https://docs.viviai.cc/en/scenarios.md) and [FAQ](https://docs.viviai.cc/en/faq.md) for more help.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.