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

> ## Agent Instructions
> The Venice API is OpenAI-compatible: use any OpenAI SDK with the base URL `https://api.venice.ai/api/v1` and a Venice API key, or pay per request from a USDC wallet through x402 with no account.
> Read model IDs from `GET /models` or `GET /models/traits` at runtime instead of hardcoding them from memory or from these pages. Models are added and retired often.
> Every model's price is in https://docs.venice.ai/pricing.md. Quote video and audio jobs with `POST /video/quote` or `POST /audio/quote` before you queue them.
> Search these docs from an MCP client at https://docs.venice.ai/mcp. The full agent guide is https://docs.venice.ai/agents.md.

# OpenCode

> Connect OpenCode to Venice AI with the built-in provider in one command, then pick from the full Venice model catalog for a private terminal coding agent.

[OpenCode](https://opencode.ai/) is an AI coding agent for the terminal. OpenCode already ships a Venice AI provider, so you connect with one command and pick a model from the full Venice catalog. No config file required.

> [!NOTE]
>
> This guide follows OpenCode 1, which the standard installer sets up. OpenCode 2 also includes Venice AI with a few label changes. See [OpenCode 2](#opencode-2).

> [card] Built-in Provider
>
> Venice AI appears in OpenCode's `/connect` list

> [card] Full Model Catalog
>
> Every Venice text model is available in `/models`

> [card] No Config Needed
>
> One command connects the account for every project

***

## Prerequisites

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

***

## Setup

**1. Connect Venice AI**

Launch OpenCode and run the connect command:

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

Search for **Venice AI** and select it.

![OpenCode's /connect palette filtered to Venice AI](https://mintcdn.com/veniceai/T5om557tGm5-bp4b/images/guides/opencode/connect-venice.png?fit=max\&auto=format\&n=T5om557tGm5-bp4b\&q=85\&s=cf4a46e95b8e845e43d9dc2848ad375b)

**2. Paste your Venice API key**

Paste the key into the **API key** field and press enter.

OpenCode stores the credential in `~/.local/share/opencode/auth.json`, so it stays available in every project.

**3. Pick a model**

Run the model command and choose a Venice model:

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

`z-ai-glm-5-3-flash` is a good default for coding: fast, inexpensive, and a 1M-token context window. See [Model IDs](#model-ids) for other options.

OpenCode also lists its own hosted free tier under similar names, for example **GLM-5.3-Flash Free** from **OpenCode** next to **GLM 5.3 Flash** from **Venice AI**. The provider name in the right column distinguishes them, and the Venice AI row is the one that uses your key and credits.

Send a small task to confirm the round trip, for example:

```txt theme={"system"}
Review the current file and suggest one safe improvement.
```

***

## Pin a default model

After you connect, OpenCode may start new sessions on a routed model such as Claude Sonnet 4.6, which costs more than the models in [Model IDs](#model-ids). To choose the model OpenCode starts with, add it to `opencode.json` in your project root (or `~/.config/opencode/opencode.json` for a global default):

```json theme={"system"}
{
  "$schema": "https://opencode.ai/config.json",
  "model": "venice/z-ai-glm-5-3-flash",
  "small_model": "venice/z-ai-glm-5-3-flash"
}
```

Model references use the `venice/<model-id>` form, and `small_model` sets the cheaper model for background tasks.

***

## Connect without `/connect`

The bundled provider also reads `VENICE_API_KEY` from the environment. Export it before launching OpenCode and Venice AI models appear in `/models` without running `/connect`:

```bash theme={"system"}
export VENICE_API_KEY="your-api-key"
```

On an OpenCode build that predates the bundled provider, or to pin the list of models OpenCode shows, configure Venice as an OpenAI-compatible provider in `opencode.json`. Keep `VENICE_API_KEY` exported:

```json theme={"system"}
{
  "$schema": "https://opencode.ai/config.json",
  "model": "venice/z-ai-glm-5-3-flash",
  "small_model": "venice/z-ai-glm-5-3-flash",
  "provider": {
    "venice": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Venice AI",
      "options": {
        "baseURL": "https://api.venice.ai/api/v1",
        "apiKey": "{env:VENICE_API_KEY}"
      },
      "models": {
        "z-ai-glm-5-3-flash": {
          "name": "GLM 5.3 Flash"
        },
        "kimi-k2-6": {
          "name": "Kimi K2.6"
        },
        "minimax-m25": {
          "name": "MiniMax M2.5"
        }
      }
    }
  }
}
```

List the models you want inside `models`. OpenCode only shows entries declared here for this provider. On builds with the bundled provider, the environment variable alone already gives you the full catalog.

***

## OpenCode 2

OpenCode 2 is a separate release line with its own installer:

```bash theme={"system"}
curl -fsSL https://opencode.ai/v2/install | bash
```

It ships a native Venice AI provider, and the setup above works with a few differences:

* The `/connect` dialog is titled **Connect an integration**. Search for **Venice AI** under **Services**, then paste your key into the **Connect Venice AI** dialog.
* Exporting `VENICE_API_KEY` before launch also enables the provider without `/connect`.
* Without a pinned model, OpenCode 2 can also start on a routed model, such as Claude Fable 5.2.
* The `opencode.json` examples on this page keep working, because OpenCode 2 still reads the OpenCode 1 config format. In native OpenCode 2 config, set the background model with `agents.title.model` instead of `small_model`. See OpenCode's [migration guide](https://opencode.ai/docs/migrate-v1) for the rest of the native format.

***

## Model IDs

A few Venice models that work well in a coding agent. The catalog changes, so use [`GET /models?type=text`](https://docs.venice.ai/api-reference/endpoint/models/list) for the current list.

| Model | Venice ID |
| - | - |
| GLM 5.3 Flash | `z-ai-glm-5-3-flash` |
| GLM 5.3 | `z-ai-glm-5-3` |
| Kimi K2.6 | `kimi-k2-6` |
| MiniMax M2.5 | `minimax-m25` |
| DeepSeek V4.1 Flash | `deepseek-v4-1-flash` |

Open-weight models such as these run fully private. Routed models from Anthropic, OpenAI, and Google run anonymized, so the upstream lab never sees your identity.

***

## Config Notes

* Keep `baseURL` set to `https://api.venice.ai/api/v1` in the manual provider block. The bundled provider already points there.
* The provider ID is `venice`, so model references use the `venice/<model-id>` form in both paths.
* Run `/connect` again at any time to replace the stored Venice key.
* Broaden context when the model supports it: several Venice models accept 1M tokens.

***

## Troubleshooting

> [accordion] Venice AI is missing from /connect
>
> Update OpenCode to the latest 1.x release with `opencode upgrade`. The Venice AI provider ships with current builds, so an older install may only offer the manual config path above.

> [accordion] Invalid API key or 401
>
> Confirm the key comes from [venice.ai/settings/api](https://venice.ai/settings/api?utm_source=venice-api-documentation), then run `/connect`, select **Venice AI**, and paste it again. OpenCode reports an auth failure rather than reaching Venice when the stored key is stale.

> [accordion] Model not available
>
> Copy the ID exactly from [Model IDs](#model-ids), the [text model catalog](https://docs.venice.ai/models/text.md), or `GET /models`, and confirm your Venice account has access to it.

> [accordion] Still stuck? See what the agent sends
>
> Run the [local debugging proxy](https://docs.venice.ai/learn/local-debug-proxy.md) between OpenCode and Venice to log every request and response, including the model ID, tools, and error body the agent actually sent, plus the last four characters of the key it used.

***

## Resources

> [card] [Venice Text Models](https://docs.venice.ai/models/text.md)
>
> Available Venice model IDs

> [card] [OpenCode 1 Provider Docs](https://opencode.ai/v1/docs/providers/)
>
> Provider list and custom provider reference

> [card] [OpenCode 2 Provider Docs](https://opencode.ai/docs/providers/)
>
> Native provider config for OpenCode 2


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