Claude Code
Use Claude Code with Codzen for enhanced reliability and management
Use Claude Code with Codzen to get provider failover, budget controls, and usage visibility for your AI-powered coding sessions.
Why Use Codzen with Claude Code?
Codzen adds a reliability and management layer between Claude Code and Anthropic's API, giving you and your organization several key benefits.
Quick Start
This guide will get you running Claude Code powered by Codzen in just a few minutes.
Step 1: Install Claude Code
macOS, Linux, WSL:
curl -fsSL https://claude.ai/install.sh | bashWindows PowerShell:
irm https://claude.ai/install.ps1 | iexnpm install -g @anthropic-ai/claude-codeStep 2: Connect Claude to Codzen
Instead of logging in with Anthropic directly, connect Claude Code to Codzen. This requires setting a few environment variables.
Requirements:
- Use
https://codzen.aifor the base URL - Provide your Codzen API key as the auth token
- Important: Explicitly blank out the Anthropic API key to prevent conflicts
Add these environment variables to your shell profile:
# Open your shell profile in nano
nano ~/.zshrc # or ~/.bashrc for Bash users
# Add these lines to the file:
export CODZEN_API_KEY="<your-codzen-api-key>"
export ANTHROPIC_BASE_URL="https://codzen.ai"
export ANTHROPIC_AUTH_TOKEN="$CODZEN_API_KEY"
export ANTHROPIC_API_KEY="" # Important: Must be explicitly empty
# After saving, restart your terminal for changes to take effectPersistence: We recommend adding these lines to your shell profile (~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish).
Create a .claude/settings.json file in your project directory:
{
"env": {
"ANTHROPIC_BASE_URL": "https://codzen.ai",
"ANTHROPIC_AUTH_TOKEN": "<your-codzen-api-key>",
"ANTHROPIC_API_KEY": ""
}
}Variable Location: Do not put these in a project-level .env file. The native Claude Code installer does not read standard .env files.
Previous Login: If you were previously logged in to Claude Code with Anthropic, run /logout in a Claude Code session to clear cached credentials before the Codzen configuration takes effect.
Step 3: Start your session
Navigate to your project directory and start Claude Code:
cd /path/to/your/project
claudeYou are now connected! Any prompt you send will be routed through Codzen.
Step 4: Verify
You can confirm your connection by running the /status command inside Claude Code.
> /status
Auth token: ANTHROPIC_AUTH_TOKEN
Anthropic base URL: https://codzen.aiYou can also check your Codzen dashboard to see your requests appearing in real-time.
How It Works
Codzen exposes an endpoint that is compatible with the Anthropic Messages API.
- Direct Connection: When you set
ANTHROPIC_BASE_URLtohttps://codzen.ai, Claude Code speaks its native protocol directly to Codzen. No local proxy server is required. - Anthropic Compatibility: Codzen's Anthropic-compatible endpoint behaves exactly like the Anthropic API. It handles model mapping and passes through advanced features like "Thinking" blocks and native tool use.
- Billing: You are billed using your Codzen credits. Usage (including reasoning tokens) appears in your Codzen dashboard.
Agent SDK
The Anthropic Agent SDK lets you build AI agents programmatically using Python or TypeScript. Since the Agent SDK uses Claude Code as its runtime, you can connect it to Codzen using the same environment variables described above.
GitHub Action
You can use Codzen with the official Claude Code GitHub Action. To adapt the example workflow for Codzen, make two changes to the action step:
- Pass your Codzen API key via
anthropic_api_key(store it as a GitHub secret namedCODZEN_API_KEY) - Set the
ANTHROPIC_BASE_URLenvironment variable tohttps://codzen.ai
- name: Run Claude Code
uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.CODZEN_API_KEY }}
env:
ANTHROPIC_BASE_URL: https://codzen.aiTroubleshooting
- Auth Errors: Ensure
ANTHROPIC_API_KEYis set to an empty string (""). If it is unset (null), Claude Code might fall back to its default behavior and try to authenticate with Anthropic servers. - Context Length Errors: If you hit context limits, consider breaking your task into smaller chunks or starting a new session.
- Privacy: Codzen does not log your source code prompts unless you explicitly opt-in to prompt logging in your account settings. See our Privacy Policy for details.