Skip to main content

Overview

The Anthropic provider enables access to Claude models from Anthropic. PicoClaw uses the native Anthropic API protocol for optimal compatibility and performance.

Configuration

Model List Format

Add Anthropic models to your model_list configuration:
{
  "model_list": [
    {
      "model_name": "claude-sonnet-4.6",
      "model": "anthropic/claude-sonnet-4.6",
      "api_key": "sk-ant-your-key",
      "api_base": "https://api.anthropic.com/v1",
      "request_timeout": 300
    }
  ],
  "agents": {
    "defaults": {
      "model_name": "claude-sonnet-4.6"
    }
  }
}

Configuration Parameters

ParameterTypeRequiredDefaultDescription
model_namestringYes-Alias for this model configuration
modelstringYes-Model identifier with anthropic/ prefix
api_keystringYes*-Your Anthropic API key (or use OAuth)
api_basestringNohttps://api.anthropic.com/v1API endpoint URL
request_timeoutintegerNo120Request timeout in seconds
*Required unless using OAuth authentication

Available Models

Anthropic provides several Claude model families:

Claude 4 Series (Latest)

  • anthropic/claude-opus-4 - Most capable, best for complex tasks
  • anthropic/claude-sonnet-4.6 - Balanced performance and speed
  • anthropic/claude-haiku-4 - Fast and efficient

Claude 3.5 Series

  • anthropic/claude-opus-3.5 - Previous generation flagship
  • anthropic/claude-sonnet-3.5 - Previous generation balanced model

Claude 3 Series

  • anthropic/claude-opus-3 - Legacy flagship model
  • anthropic/claude-sonnet-3 - Legacy balanced model
  • anthropic/claude-haiku-3 - Legacy fast model
Claude models support extended context windows. Opus and Sonnet models support up to 200K tokens.

Setup Instructions

1. Get API Key

  1. Visit Anthropic Console
  2. Sign in or create an account
  3. Navigate to API Keys section
  4. Click Create Key
  5. Copy your API key (starts with sk-ant-)

2. Configure PicoClaw

Edit ~/.picoclaw/config.json:
{
  "model_list": [
    {
      "model_name": "claude",
      "model": "anthropic/claude-sonnet-4.6",
      "api_key": "sk-ant-your-actual-key-here"
    }
  ],
  "agents": {
    "defaults": {
      "model_name": "claude",
      "max_tokens": 8192,
      "temperature": 0.7
    }
  }
}

3. Test Connection

picoclaw agent -m "Hello Claude, test my connection"

Advanced Configuration

Custom API Endpoint

Use a custom Anthropic-compatible endpoint:
{
  "model_name": "claude-proxy",
  "model": "anthropic/claude-sonnet-4.6",
  "api_base": "https://my-proxy.com/v1",
  "api_key": "sk-ant-...",
  "request_timeout": 300
}

Prompt Caching

Claude supports prompt caching to reduce costs for repeated prompts. PicoClaw automatically uses cache control for system messages:
{
  "model_name": "claude",
  "model": "anthropic/claude-sonnet-4.6",
  "api_key": "sk-ant-..."
}
Cache control is automatically applied to:
  • System prompts
  • Tool definitions
  • Large context blocks

Extended Context

Claude models support large context windows:
{
  "agents": {
    "defaults": {
      "model_name": "claude",
      "max_tokens": 8192
    }
  }
}
Context limits by model:
  • Opus: 200K tokens
  • Sonnet: 200K tokens
  • Haiku: 200K tokens

Authentication Methods

Standard API key authentication:
{
  "model_list": [
    {
      "model_name": "claude",
      "model": "anthropic/claude-sonnet-4.6",
      "api_key": "sk-ant-your-key"
    }
  ]
}

OAuth / Token (Advanced)

For OAuth-based authentication:
{
  "providers": {
    "anthropic": {
      "auth_method": "oauth",
      "api_base": "https://api.anthropic.com/v1"
    }
  }
}
Then authenticate:
picoclaw auth login --provider anthropic
Paste your API token when prompted.

Troubleshooting

Rate Limiting

If you encounter rate limits:
  • Check your plan’s rate limits in the Anthropic Console
  • Implement request throttling
  • Upgrade your plan for higher limits

Invalid API Key

Error: 401 Authentication failed
  • Verify your API key is correct
  • Ensure key starts with sk-ant-
  • Check key hasn’t been revoked in Console

Content Filtering

Some providers (like when using Claude through proxies) have content filtering:
  • Rephrase your query
  • Use different wording
  • Contact Anthropic support if false positives occur

Timeout Errors

Increase timeout for long-running requests:
{
  "model_name": "claude",
  "model": "anthropic/claude-sonnet-4.6",
  "api_key": "sk-ant-...",
  "request_timeout": 600
}

Model Selection Guide

Use CaseRecommended ModelNotes
Complex analysisclaude-opus-4Best reasoning capabilities
General tasksclaude-sonnet-4.6Best balance of speed and quality
Fast responsesclaude-haiku-4Optimized for speed
Large documentsclaude-sonnet-4.6200K context window
Cost-sensitiveclaude-haiku-4Most economical option

Cost Optimization

  1. Choose appropriate models: Use Haiku for simple tasks, Sonnet for general use, Opus only when needed
  2. Enable prompt caching: Automatically enabled for system prompts (75% cost reduction)
  3. Set max_tokens: Limit response length to reduce costs
  4. Monitor usage: Check Anthropic Console regularly
  5. Use extended context wisely: Only include necessary context

Legacy Configuration (Deprecated)

Older configuration format (still supported):
{
  "providers": {
    "anthropic": {
      "api_key": "sk-ant-your-key",
      "api_base": "https://api.anthropic.com/v1"
    }
  },
  "agents": {
    "defaults": {
      "provider": "anthropic",
      "model": "claude-sonnet-4.6"
    }
  }
}
Migrate to model_list format for better features like load balancing and fallbacks.

Build docs developers (and LLMs) love