> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ccs.kaitran.ca/llms.txt
> Use this file to discover all available pages before exploring further.

# Anthropic Direct API

> Use your own Anthropic API key to access Claude models directly

# 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

| Field                    | Details                               |
| ------------------------ | ------------------------------------- |
| **Preset ID**            | `anthropic`                           |
| **Aliases**              | None                                  |
| **Default Profile Name** | `anthropic`                           |
| **Default Model**        | `claude-sonnet-4-5-20250929`          |
| **Base URL**             | `api.anthropic.com` (auto-configured) |
| **Auth Method**          | API Key (`sk-ant-...`)                |
| **Category**             | Recommended                           |

## Quick Start

```bash theme={null}
# 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

<Steps>
  <Step title="Visit Anthropic Console">
    Go to [console.anthropic.com](https://console.anthropic.com)
  </Step>

  <Step title="Navigate to API Keys">
    Click on your profile → **Settings** → **API Keys**
  </Step>

  <Step title="Create New Key">
    Click **Create Key** and copy the generated key

    Format: `sk-ant-...`

    <Note>
      Keep this key secure. Treat it like a password. Do not commit to git or share publicly.
    </Note>
  </Step>

  <Step title="Create CCS Profile">
    ```bash theme={null}
    ccs api create --preset anthropic
    # Paste your API key when prompted
    ```
  </Step>
</Steps>

### Rotating Keys

When you need to change your API key:

```bash theme={null}
# 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

```bash theme={null}
# 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`:

```yaml theme={null}
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:

```bash theme={null}
# 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 5 Series (Latest)

| Model            | Context | Use Case                                                          |
| ---------------- | ------- | ----------------------------------------------------------------- |
| `claude-fable-5` | 1M      | Adaptive thinking, most demanding reasoning and long-horizon work |

### Claude 4.8 Series

| Model             | Context            | Use Case                                     |
| ----------------- | ------------------ | -------------------------------------------- |
| `claude-opus-4-8` | 200K (1M extended) | Adaptive extended thinking, hardest problems |

Opt in explicitly via `ANTHROPIC_MODEL` or the dashboard; the default profile model is unchanged.

### Claude 4.6 Series

| Model               | Context | Use Case                            |
| ------------------- | ------- | ----------------------------------- |
| `claude-opus-4-6`   | 200K    | Extended thinking, hardest problems |
| `claude-sonnet-4-6` | 200K    | Balanced (latest generation)        |

### Claude 4.5 Series

| Model                        | Context | Use Case                         |
| ---------------------------- | ------- | -------------------------------- |
| `claude-opus-4-1-20250805`   | 200K    | Complex reasoning, system design |
| `claude-sonnet-4-5-20250929` | 200K    | Balanced (default profile model) |
| `claude-3-5-haiku-20241022`  | 100K    | Fast responses, high volume      |

### Claude 3 Series (Previous)

| Model                      | Context | Use Case         |
| -------------------------- | ------- | ---------------- |
| `claude-3-opus-20240229`   | 200K    | Complex analysis |
| `claude-3-sonnet-20240229` | 200K    | General purpose  |
| `claude-3-haiku-20240307`  | 100K    | Fast tasks       |

## Usage Examples

### Basic Chat

```bash theme={null}
# Use default model
ccs anthropic "explain quantum computing"

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

### Model Selection

```bash theme={null}
# 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

```bash theme={null}
# 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

```bash theme={null}
# 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

```bash theme={null}
# 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:

```bash theme={null}
# 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):

| Limit               | Value  | Applies To                |
| ------------------- | ------ | ------------------------- |
| Requests/minute     | 600    | All models                |
| Tokens/minute       | Varies | Per model subscription    |
| Concurrent requests | 10     | Streaming + non-streaming |

<Note>
  Enterprise users can request higher limits at Anthropic console.
</Note>

### Cost Estimation

Visit [console.anthropic.com/pricing](https://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

| Feature         | Direct API                  | CLIProxy Claude              |
| --------------- | --------------------------- | ---------------------------- |
| **Cost**        | Pay-per-use                 | Depends on CLIProxy setup    |
| **Setup**       | Single API key              | OAuth browser login          |
| **Privacy**     | Your key, direct connection | Your key through CLIProxy    |
| **Rate limits** | Anthropic's limits          | CLIProxy's limits            |
| **Best for**    | Existing Anthropic users    | Users 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`

```bash theme={null}
# 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

```bash theme={null}
# 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](https://status.anthropic.com)
* Firewall blocked — Check firewall/proxy settings

```bash theme={null}
# 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

```bash theme={null}
# 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

```bash theme={null}
# 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):

```bash theme={null}
# Store multiple requests in a file
# Process them with batch API for 50% discount
# See Anthropic docs for batch API usage
```

## Storage Locations

| Path                    | Description                           |
| ----------------------- | ------------------------------------- |
| `~/.ccs/config.yaml`    | Stores encrypted API key in profile   |
| `~/.ccs/settings.json`  | Dashboard settings and preferences    |
| `console.anthropic.com` | API 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

<CardGroup cols={2}>
  <Card title="API Profiles" icon="server" href="/providers/concepts/api-profiles">
    Learn more about creating and managing API profiles
  </Card>

  <Card title="Claude Accounts" icon="user" href="/providers/concepts/claude-accounts">
    Compare with OAuth-based Claude accounts
  </Card>

  <Card title="All Providers" icon="sparkles" href="/providers/concepts/overview">
    Explore other available providers
  </Card>

  <Card title="Dashboard" icon="gauge" href="/features/dashboard/overview">
    Manage profiles via web interface
  </Card>
</CardGroup>
