Skip to main content

Anthropic Direct API

Use your Anthropic API key directly to access Claude models without going through CLIProxy. Perfect for users who already have Anthropic subscriptions and want direct API control.

Overview

FieldDetails
Preset IDanthropic
AliasesNone
Default Profile Nameanthropic
Default Modelclaude-sonnet-4-5-20250929
Base URLapi.anthropic.com (auto-configured)
Auth MethodAPI Key (sk-ant-...)
CategoryRecommended

Quick Start

# Create profile with your Anthropic API key
ccs api create --preset anthropic

# When prompted, enter your API key (sk-ant-...)

# Use the profile
ccs anthropic "explain this code"

Authentication

Getting Your API Key

1

Visit Anthropic Console

2

Navigate to API Keys

Click on your profile → SettingsAPI Keys
3

Create New Key

Click Create Key and copy the generated keyFormat: sk-ant-...
Keep this key secure. Treat it like a password. Do not commit to git or share publicly.
4

Create CCS Profile

ccs api create --preset anthropic
# Paste your API key when prompted

Rotating Keys

When you need to change your API key:
# Re-create or update the profile
ccs api create --preset anthropic

# Or edit the profile manually
ccs config

# Navigate to anthropic profile and update ANTHROPIC_AUTH_TOKEN

Configuration

Default Setup

# Interactive setup
ccs api create --preset anthropic

# You'll be prompted for:
# - API Key: sk-ant-...
# - Profile name (default: anthropic)

Manual Configuration

Edit ~/.ccs/config.yaml:
profiles:
  anthropic:
    env:
      ANTHROPIC_BASE_URL: ""  # Leave empty - uses official Anthropic API
      ANTHROPIC_AUTH_TOKEN: "sk-ant-your-key-here"
      ANTHROPIC_MODEL: "claude-sonnet-4-5-20250929"
      ANTHROPIC_DEFAULT_OPUS_MODEL: "claude-opus-4-1-20250805"
      ANTHROPIC_DEFAULT_SONNET_MODEL: "claude-sonnet-4-5-20250929"
      ANTHROPIC_DEFAULT_HAIKU_MODEL: "claude-3-5-haiku-20241022"

Custom Base URL (Advanced)

For organizations using Anthropic Workbench or custom deployments:
# Via CLI
ccs api create --preset anthropic --base-url https://your-custom-api.anthropic.com

# Or manual config
profiles:
  anthropic-custom:
    env:
      ANTHROPIC_BASE_URL: "https://your-custom-api.example.com"
      ANTHROPIC_AUTH_TOKEN: "sk-ant-your-key"
      ANTHROPIC_MODEL: "claude-sonnet-4-5-20250929"

Available Models

Claude 4.5 Series (Latest)

ModelTokensContextUse Case
claude-opus-4-1-20250805200K200KComplex reasoning, system design
claude-sonnet-4-5-20250929200K200KBalanced (default)
claude-3-5-haiku-20241022100K100KFast responses, high volume

Claude 3 Series (Previous)

ModelTokensContextUse Case
claude-3-opus-20240229200K200KComplex analysis
claude-3-sonnet-20240229200K200KGeneral purpose
claude-3-haiku-20240307100K100KFast tasks

Usage Examples

Basic Chat

# Use default model
ccs anthropic "explain quantum computing"

# Check current model
ccs anthropic "what model are you?"

Model Selection

# Use Opus for complex tasks
ANTHROPIC_MODEL=claude-opus-4-1-20250805 ccs anthropic "design a microservices architecture"

# Use Haiku for quick tasks
ANTHROPIC_MODEL=claude-3-5-haiku-20241022 ccs anthropic "what's 2+2?"

Temperature and Creativity

# Higher temperature = more creative
ANTHROPIC_TEMPERATURE=0.9 ccs anthropic "brainstorm creative names"

# Lower temperature = more deterministic
ANTHROPIC_TEMPERATURE=0.2 ccs anthropic "calculate the answer"

# Default = 1.0
ccs anthropic "analyze this code"

Response Length Control

# Longer responses
ANTHROPIC_MAX_TOKENS=2000 ccs anthropic "write a detailed guide"

# Shorter responses
ANTHROPIC_MAX_TOKENS=300 ccs anthropic "summarize briefly"

API Features Supported

Full Feature Support

Direct Anthropic API access supports all Claude features:
  • ✅ Vision (image analysis)
  • ✅ Extended thinking
  • ✅ Tool use (function calling)
  • ✅ Batch processing
  • ✅ Long context (200K tokens)
  • ✅ Token counting
  • ✅ Streaming

How to Enable

# Vision is handled automatically - just describe or share images
ccs anthropic "analyze this screenshot"

# Extended thinking (via ANTHROPIC_THINKING_BUDGET)
ANTHROPIC_THINKING_BUDGET=8000 ccs anthropic "solve this complex problem"

Billing & Rate Limits

Usage Tracking

Check your API usage:
# View current usage in dashboard
ccs config  # Navigate to anthropic profile section

# Check spending at console.anthropic.com/dashboard

Rate Limits

Default limits (can be increased):
LimitValueApplies To
Requests/minute600All models
Tokens/minuteVariesPer model subscription
Concurrent requests10Streaming + non-streaming
Enterprise users can request higher limits at Anthropic console.

Cost Estimation

Visit console.anthropic.com/pricing for current rates. Typical usage:
  • Claude 3.5 Sonnet: ~$3-10/month for light use
  • Extended thinking: Additional cost based on thinking tokens

Comparison with CLIProxy Providers

FeatureDirect APICLIProxy Claude
CostPay-per-useDepends on CLIProxy setup
SetupSingle API keyOAuth browser login
PrivacyYour key, direct connectionYour key through CLIProxy
Rate limitsAnthropic’s limitsCLIProxy’s limits
Best forExisting Anthropic usersUsers with CLIProxy accounts

Troubleshooting

Invalid API Key

Symptom: Error: 401 Unauthorized or Invalid authentication credentials Solutions:
  1. Verify key starts with sk-ant-
  2. Check key hasn’t expired or been revoked
  3. Copy key again from console.anthropic.com/settings/keys
  4. Update with: ccs api create --preset anthropic
# Debug: check what key is being used
ccs config | grep ANTHROPIC_AUTH_TOKEN

Rate Limited

Symptom: Error: 429 Too Many Requests or Rate limit exceeded Solutions:
  1. Wait a few minutes before retrying
  2. Reduce concurrent requests
  3. Use Haiku for high-volume tasks (cheaper, faster)
  4. Request higher limits at Anthropic console
# Switch to faster model
ANTHROPIC_MODEL=claude-3-5-haiku-20241022 ccs anthropic "quick task"

# Or reduce token limit
ANTHROPIC_MAX_TOKENS=500 ccs anthropic "brief response"

Connection Timeout

Symptom: Error: Request timeout or ECONNREFUSED Causes & Solutions:
  • Network issue — Check internet connection
  • API down — Check Anthropic status
  • Firewall blocked — Check firewall/proxy settings
# Test connection
curl -I https://api.anthropic.com

# Increase timeout if on slow network
ANTHROPIC_TIMEOUT=60000 ccs anthropic "test"

Insufficient Balance

Symptom: Error: Insufficient balance or Credit limit exceeded Solutions:
  1. Check remaining balance at console.anthropic.com/dashboard
  2. Add payment method or credits
  3. Switch to lower-cost model (Haiku)

Cost Optimization

Use Right Model for Task

# Complex tasks (use Opus)
ANTHROPIC_MODEL=claude-opus-4-1-20250805 ccs anthropic "design system architecture"

# Routine tasks (use Sonnet - default)
ccs anthropic "fix this function"

# Quick tasks (use Haiku)
ANTHROPIC_MODEL=claude-3-5-haiku-20241022 ccs anthropic "translate to Spanish"

Limit Response Length

# Reduce tokens to lower cost
ANTHROPIC_MAX_TOKENS=500 ccs anthropic "summarize in 100 words"

Batch Processing

For bulk operations, use Anthropic’s Batch API (available through direct API):
# Store multiple requests in a file
# Process them with batch API for 50% discount
# See Anthropic docs for batch API usage

Storage Locations

PathDescription
~/.ccs/config.yamlStores encrypted API key in profile
~/.ccs/settings.jsonDashboard settings and preferences
console.anthropic.comAPI key management and usage tracking

Security Best Practices

  1. Never commit API keys — Use .gitignore for config files
  2. Rotate keys regularly — Generate new keys, revoke old ones
  3. Use environment variables — For CI/CD pipelines instead of files
  4. Monitor usage — Check console.anthropic.com regularly for suspicious activity
  5. Limit key scope — Create separate keys for different applications if possible

Next Steps

API Profiles

Learn more about creating and managing API profiles

Claude Accounts

Compare with OAuth-based Claude accounts

All Providers

Explore other available providers

Dashboard

Manage profiles via web interface