Anthropic Provider

The Anthropic provider connects GoClaw to Claude models via the Anthropic API.

Configuration

{
  "llm": {
    "providers": {
      "anthropic": {
        "driver": "anthropic",
        "apiKey": "YOUR_API_KEY",
        "promptCaching": true
      }
    },
    "agent": {
      "models": ["anthropic/claude-sonnet-4-20250514"]
    }
  }
}

Note: The setup wizard (goclaw setup) can detect ANTHROPIC_API_KEY from your environment and offer to write it to config.

Provider Options

FieldTypeDefaultDescription
driverstring-Must be "anthropic"
apiKeystring-Anthropic API key
maxTokensint200000Context window size
promptCachingbooltrueEnable prompt caching (reduces cost)
timeoutSecondsint300Request timeout

Models are specified in the agent.models array using provider/model format (e.g., anthropic/claude-sonnet-4-20250514).

Models

ModelContextBest For
claude-sonnet-4-20250514200kGeneral agent use, balanced
claude-opus-4-20250514200kComplex reasoning
claude-3-haiku-20240307200kFast, cheap summarization
claude-3-5-sonnet-20241022200kPrevious generation

Features

Prompt Caching

When promptCaching: true, the system prompt is cached server-side by Anthropic. This reduces costs by up to 90% for repeated requests with the same system prompt.

Cache expires after 5 minutes of inactivity.

Extended Thinking

Anthropic supports extended thinking (reasoning) on Claude 3.5+ models. Configure per-user in users.json:

{
  "users": [
    {
      "name": "Alice",
      "role": "owner",
      "thinking": true,
      "thinkingLevel": "medium"
    }
  ]
}
LevelToken BudgetUse Case
off0Disabled
minimal1,024Quick responses
low4,096Light reasoning
medium10,000Balanced (default)
high25,000Deep reasoning
xhigh50,000Maximum effort

Multi-Provider Setup

For setups with multiple providers:

{
  "llm": {
    "providers": {
      "claude": {
        "driver": "anthropic",
        "apiKey": "YOUR_API_KEY",
        "promptCaching": true
      },
      "ollama": {
        "driver": "ollama",
        "url": "http://localhost:11434"
      }
    },
    "agent": {
      "models": ["claude/claude-sonnet-4-20250514"]
    },
    "summarization": {
      "models": ["ollama/qwen2.5:7b"]
    }
  }
}

Troubleshooting

“invalid_api_key”

Verify your API key:

  1. Check it starts with sk-ant-
  2. Verify it’s not expired in the Anthropic console
  3. Check the apiKey field in goclaw.json

Rate Limiting

If you hit rate limits, the provider enters cooldown with automatic retry. Check status with /llm command.

Model Not Available

Some models require specific API access levels. Check your Anthropic account permissions.


See Also