> ## Documentation Index
> Fetch the complete documentation index at: https://veniceai-mintlify-6ce01df5.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Use OpenCode with Venice AI through an OpenAI-compatible custom provider

[OpenCode](https://opencode.ai/) is an AI coding agent for the terminal. Venice works through OpenCode's custom provider config using the OpenAI-compatible adapter and a custom base URL.

<CardGroup cols={3}>
  <Card title="Custom Provider" icon="sliders">
    Add Venice as a provider in `opencode.json`
  </Card>

  <Card title="OpenAI Compatible" icon="plug">
    Uses Venice's `/chat/completions` endpoint
  </Card>

  <Card title="Environment Key" icon="key">
    Reads your API key from `VENICE_API_KEY`
  </Card>
</CardGroup>

***

## Prerequisites

* A Venice API key from [venice.ai/settings/api](https://venice.ai/settings/api)
* OpenCode installed and working on your machine

***

## Setup

<Steps>
  <Step title="Set your Venice API key">
    Export your Venice API key in the shell where you run OpenCode:

    ```bash theme={"system"}
    export VENICE_API_KEY="your-api-key"
    ```
  </Step>

  <Step title="Create an OpenCode config file">
    For a project-specific setup, create `opencode.json` in your project root.

    For a global setup, use `~/.config/opencode/opencode.json` instead.
  </Step>

  <Step title="Add the Venice provider">
    Paste this config into `opencode.json`:

    ```json theme={"system"}
    {
      "$schema": "https://opencode.ai/config.json",
      "model": "venice/zai-org-glm-5-1",
      "small_model": "venice/zai-org-glm-5-1",
      "provider": {
        "venice": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "Venice AI",
          "options": {
            "baseURL": "https://api.venice.ai/api/v1",
            "apiKey": "{env:VENICE_API_KEY}"
          },
          "models": {
            "zai-org-glm-5-1": {
              "name": "GLM 5.1"
            },
            "kimi-k2-5": {
              "name": "Kimi K2.5"
            },
            "minimax-m25": {
              "name": "MiniMax M2.5"
            }
          }
        }
      }
    }
    ```
  </Step>

  <Step title="Run OpenCode">
    Start OpenCode from the same project directory:

    ```bash theme={"system"}
    opencode
    ```

    OpenCode will load `opencode.json`, use `VENICE_API_KEY`, and route the selected Venice model through `https://api.venice.ai/api/v1`.
  </Step>
</Steps>

***

## Verify the Setup

Inside OpenCode, run:

```txt theme={"system"}
/models
```

You should see the Venice models from your config. Select one, then send a small test prompt.

If you set `"model": "venice/zai-org-glm-5-1"` as shown above, OpenCode should use that Venice model by default. You can change the default by replacing `zai-org-glm-5-1` with any model ID from the [text model catalog](/models/text) and adding it to the `models` map.

***

## Config Notes

* Keep `baseURL` set to `https://api.venice.ai/api/v1`. OpenCode's OpenAI-compatible adapter uses this base URL for chat completions.
* Keep `npm` set to `@ai-sdk/openai-compatible` for Venice's OpenAI-compatible chat endpoint.
* The provider ID is `venice`, so model references use the `venice/<model-id>` format.
* If you prefer OpenCode's `/connect` flow, choose **Other**, use `venice` as the provider ID, paste your Venice API key, and remove `options.apiKey` from the config.

<Info>
  OpenCode already supports custom provider `baseURL` values and OpenAI-compatible providers through `@ai-sdk/openai-compatible`. No OpenCode core provider changes are required for Venice.
</Info>

***

## Resources

<CardGroup cols={2}>
  <Card title="Venice Text Models" icon="list" href="/models/text">
    Available Venice model IDs
  </Card>

  <Card title="OpenCode Provider Docs" icon="book" href="https://opencode.ai/docs/providers/">
    Custom provider and base URL reference
  </Card>
</CardGroup>
