Rate limits, model strings, authentication, streaming, errors — the technical reference developers use at runtime.
Claude API rate limits are governed by Tier structures based on your deposit history. Tier 1 has limits of 20,000 Tokens Per Mi...
To call Claude models in API requests, use model strings: 'claude-3-5-sonnet-20241022' for Claude 3.5 Sonnet, 'claude-3-5-haiku...
Authenticate with the Claude API by passing your API key in the 'x-api-key' request header. Specify the SDK version header 'ant...
An HTTP 529 error indicates that Anthropic's servers are overloaded and unable to handle the request. Handle this error by impl...
To stream Claude API responses, set the request parameter 'stream' to true. The server will emit Server-Sent Events containing ...
All current Claude 3 and Claude 3.5 models support a maximum context window of 200,000 tokens (approximately 150,000 words or 5...
Pass a system prompt by declaring the top-level 'system' string parameter in your API body request payload. Do not mix system i...
Input tokens represent all prompt text, system instructions, and tool definitions sent to Claude, billed at a lower rate (e.g.,...
API keys are best for back-end applications using secret environment keys. OAuth 2.0 is required for client-facing integrations...
Implement prompt caching by attaching the cache_control metadata block '{"type": "ephemeral"}' to blocks in your prompt (system...
To force JSON output, declare your required JSON schema in a tool definition and set the tool_choice block to force a call to t...
Claude 3.5 Sonnet and Claude 3.5 Haiku support a maximum completion output of 8,192 tokens per single API request. Claude 3 Opu...
The temperature parameter ranges from 0.0 to 1.0. Lower settings (e.g. 0.0) yield deterministic, highly factual answers, while ...
top_k limits selection to the K highest probability next tokens, while top_p (nucleus sampling) selects from the smallest set o...
Structure your system prompts using XML tags (e.g., <instructions>, <context>, <rules>) to separate guideline...
To send an image to the Claude API, include an image content block in your messages array, passing the base64-encoded file stri...
To send a PDF, pass it as a document content block in the messages array, base64-encoded, using the media type application/pdf.
Do not call the Claude API directly from client-side browser scripts, as it will trigger CORS policy blocks and expose your API...
Log in to the Anthropic Console, go to Settings > Billing, and configure your Monthly Spending Limit to block API requests once...
Anthropic officially maintains two developer libraries: the Python SDK (package: 'anthropic') and the TypeScript/JavaScript SDK...
Claude API rate limits are governed by Tier structures based on your deposit history. Tier 1 has limits of 20,000 Tokens Per Minute (TPM) and 50 Requests Per Minute (RPM), scaling up to Tier 5 which provides up to 2,500,000 TPM and 4,000 RPM.
To call Claude models in API requests, use model strings: 'claude-3-5-sonnet-20241022' for Claude 3.5 Sonnet, 'claude-3-5-haiku-20241022' for Claude 3.5 Haiku, and 'claude-3-opus-20240229' for Claude 3 Opus.
Authenticate with the Claude API by passing your API key in the 'x-api-key' request header. Specify the SDK version header 'anthropic-version' to ensure compatibility.
An HTTP 529 error indicates that Anthropic's servers are overloaded and unable to handle the request. Handle this error by implementing retry loops using exponential backoff with random jitter.
To stream Claude API responses, set the request parameter 'stream' to true. The server will emit Server-Sent Events containing JSON-RPC event chunks for message start, content delta updates, and completion.