How to Configure Anthropic Models with OpenClaude: A Complete Guide

Set ANTHROPIC_API_KEY and use --provider anthropic --model <model-id> or OPENAI_MODEL=anthropic/<model-id> to route requests through OpenClaude's built-in Anthropic integration.

OpenClaude treats Anthropic as a first-party provider with dedicated routing, metadata, and transport layers. Whether you're calling Claude 3 Opus directly or routing through a custom proxy, configuration happens through environment variables and CLI flags defined in the provider system.

Selecting an Anthropic Model

You can specify Anthropic models through two primary mechanisms:

CLI Flag Method

openclaude \
  --provider anthropic \
  --model claude-3-opus-20240229 \
  --prompt "Write a TypeScript function that sums an array."

Environment Variable Method

export OPENAI_MODEL="anthropic/claude-sonnet-3.5"
openclaude --prompt "Explain quantum entanglement in plain English."

Both approaches resolve to the same internal route. In src/utils/providerValidation.ts, the validator checks that any model with the anthropic/* prefix belongs to the Anthropic vendor before processing.

Required Credentials

Anthropic integration requires minimal environment setup:

Variable Required Purpose
ANTHROPIC_API_KEY Yes Bearer token for API authentication
ANTHROPIC_BASE_URL No Custom proxy endpoint (defaults to https://api.anthropic.com)

These variables are declared in the Anthropic descriptor's envVarConfig and consumed by the transport layer. In src/utils/teleport/api.ts, the transport automatically injects required headers including anthropic-version and anthropic-beta at lines 274-280.

Minimal Configuration Example


# .env

ANTHROPIC_API_KEY="sk-ant-xxxxxxxxxxxxxxxxxxxx"

No base URL is needed for standard Anthropic API access.

Architecture: How Configuration Flows

OpenClaude separates Anthropic configuration into three distinct layers:

Layer Responsibility Key File
Metadata Descriptor files declare defaults, env-var contracts, and capabilities src/integrations/define.ts
Routing Maps user config to concrete provider routes src/utils/providerProfiles.ts
Transport Executes HTTP requests with proper headers src/utils/teleport/api.ts

The default Anthropic profile is identified by ANTHROPIC_DEFAULT_PROFILE_ID at lines 984-990 of providerProfiles.ts. When you specify --provider anthropic, this profile loads automatically.

Custom Anthropic Proxy Configuration

For organizations routing through an intermediate proxy, OpenClaude supports the anthropic-proxy transport kind.

Environment Setup for Custom Proxy


# .env

MY_PROXY_TOKEN="my-proxy-token"
MY_PROXY_BASE_URL="https://my-proxy.example/v1"
MY_PROXY_MODEL="claude-3-haiku-20240307"

export ANTHROPIC_API_KEY="$MY_PROXY_TOKEN"
export ANTHROPIC_BASE_URL="$MY_PROXY_BASE_URL"
export OPENAI_MODEL="anthropic/claude-3-haiku-20240307"

Creating a Custom Proxy Descriptor

Add a new TypeScript file under src/integrations/anthropicProxies/:

// src/integrations/anthropicProxies/my-proxy.ts
import { defineAnthropicProxy } from '../define.js';

export default defineAnthropicProxy({
  id: 'my-proxy',
  label: 'My Anthropic Proxy',
  classification: 'anthropic-proxy',
  defaultBaseUrl: 'https://my-proxy.example/v1',
  defaultModel: 'claude-3-sonnet-20240229',
  setup: {
    requiresAuth: true,
    authMode: 'token',
    credentialEnvVars: ['MY_PROXY_TOKEN'],
    setupPrompt: 'Paste your My-Proxy token.',
  },
  envVarConfig: {
    authTokenEnvVar: 'MY_PROXY_TOKEN',
    baseUrlEnvVar: 'MY_PROXY_BASE_URL',
    modelEnvVar: 'MY_PROXY_MODEL',
  },
  capabilities: {
    supportsStreaming: true,
    supportsVision: false,
    supportsFunctionCalling: true,
    supportsJsonMode: true,
    supportsReasoning: true,
  },
  transportConfig: {
    kind: 'anthropic-proxy',
  },
  usage: { supported: true },
});

After creating the descriptor, regenerate the integration loader:

bun run integrations:generate

Complete Configuration Examples

Direct Anthropic API Access


# .env

ANTHROPIC_API_KEY="sk-ant-abc123..."

# CLI

openclaude \
  --provider anthropic \
  --model claude-3-opus-20240229 \
  --prompt "Refactor this Python script for readability."

Enterprise Proxy with Custom Headers


# .env

ENTERPRISE_ANTHROPIC_KEY="ent-token-xyz789"
ENTERPRISE_BASE_URL="https://ai-gateway.company.internal/anthropic"

export ANTHROPIC_API_KEY="$ENTERPRISE_ANTHROPIC_KEY"
export ANTHROPIC_BASE_URL="$ENTERPRISE_BASE_URL"
export OPENAI_MODEL="anthropic/claude-3-5-sonnet-20240620"

openclaude --prompt "Generate a SQL query for monthly revenue trends."

Key Files for Anthropic Configuration

Understanding these source files helps debug configuration issues:

Summary

  • Authentication: Set ANTHROPIC_API_KEY as the minimum requirement
  • Model selection: Use --provider anthropic --model <id> or OPENAI_MODEL=anthropic/<id>
  • Custom proxies: Set ANTHROPIC_BASE_URL or create a full proxy descriptor with transportConfig.kind: 'anthropic-proxy'
  • Header injection: The transport layer in teleport/api.ts handles anthropic-version and anthropic-beta automatically
  • Extensibility: New proxy configurations only require descriptor changes—no modifications to routing or transport code

Frequently Asked Questions

How do I switch between different Anthropic models?

Use the --model flag with any Anthropic model ID, or set OPENAI_MODEL=anthropic/<model-id>. The system validates the model against Anthropic's vendor list in providerValidation.ts before executing requests.

Can I use Anthropic through a corporate proxy or gateway?

Yes. Either set ANTHROPIC_BASE_URL to your gateway endpoint, or create a custom proxy descriptor in src/integrations/anthropicProxies/ using defineAnthropicProxy. The descriptor approach gives you full control over environment variable names and transport configuration.

Why does OpenClaude use OPENAI_MODEL for Anthropic models?

The OPENAI_MODEL environment variable accepts a vendor-prefixed format (anthropic/<model-id>) to maintain backward compatibility while supporting multiple providers. The parser routes anthropic/* values to the Anthropic provider profile automatically.

What headers does OpenClaude send to the Anthropic API?

The transport layer in src/utils/teleport/api.ts injects anthropic-version and anthropic-beta headers along with the standard Authorization: Bearer header containing your ANTHROPIC_API_KEY.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →