Anthropic Claude Integration
Anthropic provides Claude, a family of state-of-the-art language models known for extended thinking, safety, and nuanced understanding. This guide shows you how to integrate Anthropic Claude with Lava’s payment platform.Quick Reference
- Authentication:
x-api-keyheader (NOTAuthorization: Bearer) - Additional Header:
anthropic-version: 2023-06-01(required) - Endpoint:
https://api.anthropic.com/v1/messages - Request Format: Anthropic-specific (
max_tokensrequired,systemseparate) - Usage Data: Available in response body at
data.usage - Billing Basis: Tokens (input + output)
- BYOK Support: Yes (managed keys + bring your own key)
Current Models (October 2025)
Active Models
claude-sonnet-4-5-20250929- Latest Sonnet (September 2025)claude-opus-4-1-20250805- Latest Opus (August 2025)claude-opus-4-20250514- Opus 4 (May 2025)claude-sonnet-4-20250514- Sonnet 4 (May 2025)claude-haiku-4-5-20251001- Latest Haiku (October 2025)claude-3-7-sonnet-20250219- Sonnet 3.7 (February 2025)claude-3-5-haiku-20241022- Haiku 3.5 (October 2024)claude-3-haiku-20240307- Haiku 3 (March 2024)
Model Families
- Opus: Most capable, best for complex tasks (creative writing, strategy, research)
- Sonnet: Balanced intelligence and speed (content creation, analysis, coding)
- Haiku: Fastest, most cost-effective (customer support, moderation, extraction)
Pricing (per million tokens)
| Model | Input | Output | Cache Write (5min) | Cache Read |
|---|---|---|---|---|
| Opus 4.1 | $15 | $75 | $18.75 | $1.50 |
| Sonnet 4.5 | $3 | $15 | $3.75 | $0.30 |
| Haiku 4.5 | $1 | $5 | $1.25 | $0.10 |
Integration Example
Prerequisites
- Lava forward token (get from dashboard: Build > Secret Keys)
- Backend server (CORS blocks frontend calls for security)
Environment Setup
.env.local
Complete Example
Request Format
Anthropic-Specific Format:Key Differences from OpenAI:
max_tokensis required (not optional)systemprompt is separate field (not in messages array)- Uses
x-api-keyheader instead ofAuthorization: Bearer - Requires
anthropic-versionheader
Response Format
Key Features
Extended Thinking
Claude models support extended reasoning with thinking tokens tracked separately for transparency and billing.Prompt Caching
Usecache_control blocks to cache frequently used context (system prompts, documents, code) for up to 5 minutes:
- Cache writes: 25% markup on input token price
- Cache reads: 90% discount from input token price
- Cache duration: 5 minutes
Vision Support
All Claude 3+ models support image inputs:Message Batches
Process multiple requests asynchronously at 50% discount:Usage Tracking
Location: All usage data is in the response body atdata.usage (NOT in headers).
Fields:
input_tokens- Prompt tokens consumedoutput_tokens- Completion tokens generatedcache_read_input_tokens- Cached input tokens (90% discount)cache_creation_input_tokens- Cache write tokens (25% markup)
x-lava-request-id- Request ID for dashboard lookup
BYOK Support
Anthropic supports BYOK (Bring Your Own Key) mode. See the BYOK Guide for details on using your own Anthropic API key with Lava metering.Official Documentation
For complete API details, see the official Anthropic documentation.Documentation current as of October 2025. Model availability subject to change.