> ## 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.

# Claude Code

> Route Claude Code CLI requests through Venice with claude-code-router for pay-per-token access to Claude Opus, Sonnet, and Fable coding models.

[Claude Code](https://code.claude.com/docs) is Anthropic's CLI tool for agentic coding. This guide shows you how to run it through Venice for anonymized, pay-per-token access to Claude models.

> [card] Pay Per Token
>
> No subscription. Pay only for what you use

> [card] Claude Models
>
> Access current Opus, Sonnet, and Fable models through Venice

> [card] Prompt Caching
>
> Venice caching works alongside Claude Code

## Why You Need a Router

Claude Code connects directly to Anthropic's API by default. To use it with Venice, you need [claude-code-router](https://github.com/musistudio/claude-code-router), an open-source local proxy that:

**1. Intercepts**

Catches Claude Code's outgoing requests before they reach Anthropic

**2. Transforms**

Converts Anthropic Messages requests into Venice's OpenAI-compatible chat format

**3. Redirects**

Forwards requests to `api.venice.ai/api/v1/chat/completions`

***

## Prerequisites

> [card] [Venice Account](https://venice.ai/settings/api?utm_source=venice-api-documentation)
>
> With Venice credits

> [card] [Node.js](https://nodejs.org/)
>
> v22 or higher

> [card] [Claude Code](https://code.claude.com/docs)
>
> Installed via npm

***

## Setup

**1. Install or update Claude Code**

Install the latest Claude Code CLI:

```bash theme={"system"}
npm install -g @anthropic-ai/claude-code@latest
claude --version
```

**2. Install Claude Code Router**

```bash theme={"system"}
npm install -g @musistudio/claude-code-router@latest
npm list -g @musistudio/claude-code-router --depth=0
```

**3. Get Your API Key**

Generate a key from [venice.ai/settings/api](https://venice.ai/settings/api?utm_source=venice-api-documentation). You will add it to CCR in the next step.

**4. Add Venice as a provider**

Start CCR's management UI:

```bash theme={"system"}
ccr ui
```

On the **Providers** page, choose **Add provider** and then **Other / custom API endpoint**. Enter:

* **Name:** `Venice`
* **API endpoint:** `https://api.venice.ai/api/v1`
* **API key:** your Venice API key

CCR should detect **OpenAI Chat** automatically. If it does not, open **Advanced settings**, turn off automatic protocol detection, and select **OpenAI Chat**.

Use **Search models** or **Custom models** to add the Claude models you want, then run **Check Connection** and save the provider. The connection check sends a real request with a one-token output limit.

**5. Start the gateway**

Open **Server** in `ccr ui` and click **Start**, or run `ccr start`. Claude Code reaches Venice through this local gateway on `http://127.0.0.1:3456`, so requests fail with `ConnectionRefused` until it runs.

**6. Create a Claude Code profile**

In **Agent Config**, choose **Add profile** and then **Claude Code**:

* Name the profile `Claude Code - Venice`.
* Keep **Effect scope** set to **Only opened from CCR** while testing.
* Choose **CLI only** or **CLI & APP**.
* Set **Model** to a Venice model such as `Venice/claude-opus-4-8`.
* To keep every Claude Code tier on Venice, set the optional Fable, Opus, Sonnet, and Haiku model fields to Venice models too.

Save the profile.

**7. Launch and verify**

Launch the profile by name:

```bash theme={"system"}
ccr "Claude Code - Venice"
```

In Claude Code:

1. Run `/context` and confirm the context window matches the selected model. For `claude-opus-4-8`, it should show `1M`.
2. Run `/model` if you want to switch to another Venice model; 1M variants are marked **1M context**.
3. Send a test message, then check **Request logs** in CCR to confirm that it used Venice.

***

## Supported Models

| Model | Venice ID | Context |
| - | - | - |
| Claude Fable 5.2 | `claude-fable-5-2` | 1M |
| Claude Fable 5.1 | `claude-fable-5-1` | 1M |
| Claude Fable 5 | `claude-fable-5` | 1M |
| Claude Opus 5.5 | `claude-opus-5-5` | 1M |
| Claude Opus 5.5 Fast | `claude-opus-5-5-fast` | 1M |
| Claude Opus 5 | `claude-opus-5` | 1M |
| Claude Opus 5 Fast | `claude-opus-5-fast` | 1M |
| Claude Opus 4.8 | `claude-opus-4-8` | 1M |
| Claude Opus 4.7 | `claude-opus-4-7` | 1M |
| Claude Opus 4.6 | `claude-opus-4-6` | 1M |
| Claude Opus 4.5 | `claude-opus-4-5` | 198K |
| Claude Sonnet 5.5 | `claude-sonnet-5-5` | 1M |
| Claude Sonnet 5 | `claude-sonnet-5` | 1M |
| Claude Sonnet 4.6 | `claude-sonnet-4-6` | 1M |
| Claude Haiku 5.5 | `claude-haiku-5-5` | 1M |

The catalog changes over time. Use **Search models** in CCR or [`GET /models?type=text`](https://docs.venice.ai/api-reference/endpoint/models/list) for the current list and limits.

> [!NOTE]
>
> Claude Code is optimized for Claude models. While other models available through Venice (GPT, DeepSeek, Grok, etc.) may work, we cannot guarantee an equivalent experience since Claude Code relies on Claude-specific features like extended thinking. For other models, consider using Venice's [standard API](https://docs.venice.ai/api-reference/endpoint/chat/completions.md).

***

## Updating an Existing Installation

Update CCR before troubleshooting an existing installation:

```bash theme={"system"}
npm install -g @musistudio/claude-code-router@latest
npm list -g @musistudio/claude-code-router --depth=0
ccr ui
```

Current CCR releases store live configuration in `~/.claude-code-router/config.sqlite`. An older `config.json` is imported when the database does not exist. After migration, make changes through `ccr ui` instead of continuing to edit `config.json`.

If a background process is still running after an update, restart it:

```bash theme={"system"}
ccr stop
ccr start
```

***

## Prompt Caching

Venice [prompt caching](https://docs.venice.ai/guides/features/prompt-caching.md) works with Claude Code's native cache markers. No additional cache transformer is required for the normal setup.

***

## Troubleshooting

> [accordion] Context reaches 100% early or compaction fails
>
> 1. Update CCR with `npm install -g @musistudio/claude-code-router@latest`.
> 2. Launch a new Claude Code session from the CCR profile.
> 3. Run `/model` and select the Venice entry marked **1M context**.
> 4. Run `/context` and confirm that the window is `1M`, not `200K`.
>
> Older CCR releases may not expose the correct context window or token usage to Claude Code.

> [accordion] CCR crashes during startup
>
> Confirm Node.js 22 or newer and update CCR:
>
> ```bash theme={"system"}
> node --version
> npm list -g @musistudio/claude-code-router --depth=0
> ```
>
> Use `ccr serve` to run in the foreground and expose the original startup error. A `Cannot read properties of undefined (reading 'error')` stack from `server.logger.error` indicates an outdated CCR installation; update it before investigating further.

> [accordion] Claude Code reports ConnectionRefused
>
> Start the gateway and verify its health:
>
> ```bash theme={"system"}
> ccr start
> curl http://127.0.0.1:3456/health
> ```
>
> A failed health check means the local CCR gateway is unavailable; the request has not reached Venice.

> [accordion] Configuration changes are ignored
>
> Open `ccr ui` and make the change there. Current CCR releases store configuration in `config.sqlite`; `config.json` is only a migration source for older installations.

> [accordion] Still stuck? See what the agent sends
>
> Run the [local debugging proxy](https://docs.venice.ai/learn/local-debug-proxy.md) between Claude Code 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 API Docs](https://docs.venice.ai/api-reference/api-spec.md)
>
> Full API reference

> [card] [claude-code-router](https://github.com/musistudio/claude-code-router)
>
> Source code and issues

> [card] [CCR Releases](https://github.com/musistudio/claude-code-router/releases)
>
> Current versions and release notes


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