Skip to main content
Claude Code is Anthropic’s CLI tool for agentic coding. This guide shows you how to run it through Venice AI for pay-per-token access to Claude Opus 4.5/4.6 and Sonnet 4.5/4.6.

Pay Per Token

No subscription. Pay only for what you use

Claude Models

Access Opus 4.5/4.6 and Sonnet 4.5/4.6 through Venice

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, an open-source local proxy that:

Intercepts

Catches Claude Code’s outgoing requests before they reach Anthropic

Transforms

Converts request format and maps model IDs (e.g., claude-opus-4-5)

Redirects

Forwards requests to Venice at api.venice.ai/api/v1/chat/completions

Prerequisites

Venice Account

With API credits

Node.js

v18 or higher

Claude Code

Installed via npm

Setup

1

Install Claude Code

If you haven’t already, install Anthropic’s Claude Code CLI:
2

Install the Router

3

Get Your API Key

Generate a key from venice.ai/settings/api. You’ll paste it directly in the config file in the next step.
4

Create Configuration

Create the config directory:
Then create ~/.claude-code-router/config.json with your preferred editor:
Paste the following configuration:
If you modify config.json while the router is running, restart it with ccr restart to apply changes.
5

Launch

Start the router, then Claude Code:
Or use the activation method:

Supported Models

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.

Router Features

The router provides several useful features beyond basic routing:
Use the /model command inside Claude Code to switch models without restarting:
Useful when you want Opus for complex tasks and Sonnet for quick iterations.
Prefer a GUI? Launch the web-based config editor:
This opens a browser interface for editing your config.json without touching the file directly.
The Router config section controls which model handles different task types:You can route different scenarios to different models. For example, use Sonnet for background tasks to save costs.
If something isn’t working, check the logs:
Set "LOG_LEVEL": "debug" in your config for more verbose output.

Caching Behavior

Venice prompt caching works alongside Claude Code’s native cache markers. Venice automatically detects when Claude Code sends cache_control fields and adjusts its caching strategy accordingly.
The default configuration lets both systems cooperate:
  • Claude Code sends its native cache_control markers
  • Venice adds caching around them with a 5-minute TTL
  • Both systems share the 4-block cache limit
This works well for active coding sessions where you’re making frequent requests.
Add cleancache to the transformer if you:
  • Are hitting the 4-block cache limit errors
  • Experience strange caching behavior
  • Prefer Venice’s 1-hour TTL for longer sessions
This strips Claude Code’s cache markers, giving Venice full control with a longer TTL.

Resources

Venice API Docs

Full API reference

claude-code-router

Source code and issues