Skip to main content

Overview

The Anthropic provider enables ZeroClaw to use Claude models via the Anthropic API. It supports both API key authentication and OAuth setup tokens. Provider ID: anthropic Base URL: https://api.anthropic.com API Version: 2023-06-01

Authentication

Environment Variables

Credentials are resolved in the following order:
  1. ANTHROPIC_API_KEY - Standard API key
  2. ANTHROPIC_OAUTH_TOKEN - Setup token (OAuth)
  3. Generic fallback: ZEROCLAW_API_KEY or API_KEY

Setup Token (OAuth)

Setup tokens use the format sk-ant-oat01-* and require special headers:
Setup tokens send:
  • Authorization: Bearer <token>
  • anthropic-beta: oauth-2025-04-20

API Key

Standard API keys use the format sk-ant-api* and send:
  • x-api-key: <key>

Configuration

Config File

Custom Base URL

For proxy or custom endpoints:

Features

Native Tool Calling

Supported: Yes The provider converts ZeroClaw’s tool definitions to Anthropic’s native format:
Tool results are sent as structured content blocks:

Vision Support

Supported: Yes Images are sent as base64-encoded inline data:
Image markers in user messages are automatically parsed:

Prompt Caching (Automatic)

Enabled by default for cost optimization.

System Prompt Caching

System prompts larger than 3KB (approximately 1024 tokens) are automatically cached:

Conversation Caching

Conversations with more than 4 non-system messages automatically cache the last message:

Tool Definition Caching

When tools are provided, the last tool definition is automatically cached:

Token Usage Tracking

Supported: Yes Usage data is extracted from response:

API Endpoints

Chat Completion

Endpoint: POST /v1/messages Request:
Response:

Request Configuration

Max Tokens

Default: 4096 Fixed in the provider implementation. Use model-specific limits for production.

Temperature

Range: 0.0 - 2.0 Default: 0.7 (from config) Controls response randomness.

Timeouts

  • Request timeout: 120 seconds
  • Connection timeout: 10 seconds

Message Format

System Prompt

Sent as top-level system field:
Or as structured blocks with cache control:

User Messages

Simple text:
With images:

Assistant Messages

Text only:
With tool calls:

Tool Results

Sent as user message with tool_result blocks:

Stop Reasons

Normalized stop reasons:

Error Handling

Authentication Errors

Solution: Export the appropriate environment variable.

Rate Limiting

HTTP 429 responses include retry information in headers. ZeroClaw’s quota adapter automatically extracts rate limit metadata.

API Errors

Error responses are sanitized before display:

Provider Capabilities

Warmup

Supported: Yes Sends a minimal request to establish TLS and HTTP/2 connections:
Non-blocking and accepts any response (including errors) as warmup is for connection setup only.

Example Usage

Simple Chat

With Tools

With Vision

Limitations

  • Max tokens is fixed at 4096 (not configurable per request)
  • Only ephemeral cache type is supported
  • System prompt is consolidated (multiple system messages merge)
  • Image format auto-detection from base64 data URI