Anthropic Provider
The Anthropic provider gives you access to Claude models, including the efficient Haiku, balanced Sonnet, and powerful Opus variants.Configuration
API Key Setup
Set your Anthropic API key in your.env file:
config/llm-magic.php:
Available Models
LLM Magic supports the following Claude models:Claude 3 Haiku
- claude-3-haiku-20240307 - Fast and cost-effective model
- claude-3-5-haiku-latest - Latest Haiku 3.5 model
Claude 3 Sonnet
- claude-3-sonnet-20240229 - Balanced performance
- claude-3-5-sonnet-latest - Latest Sonnet 3.5 model
- claude-3-5-sonnet-20241022 - Sonnet 3.5 with computer use capabilities
- claude-3-7-sonnet-latest - Latest Sonnet 3.7 model
Claude 3 Opus
- claude-3-opus-latest - Most powerful Claude model
Model Constants
Use these constants for type safety:Usage
Using the Constructor
Create an Anthropic model instance with any model name:Using Static Factory Methods
LLM Magic provides convenient static methods for common models:Getting Available Models
Retrieve a list of all available Anthropic models:Model Costs
Anthropic models include built-in cost tracking with support for prompt caching:| Model | Input Cost (per 1M tokens) | Cache Writes | Cache Hits | Output Cost (per 1M tokens) |
|---|---|---|---|---|
| Claude 3.7 Sonnet | $3.00 | $3.75 | $0.30 | $15.00 |
| Claude 3.5 Sonnet | $3.00 | $3.75 | $0.30 | $15.00 |
| Claude 3.5 Haiku | $0.80 | $1.00 | $0.08 | $4.00 |
| Claude 3 Haiku | $0.25 | $0.30 | $0.03 | $1.25 |
| Claude 3 Opus | $15.00 | $18.75 | $1.50 | $75.00 |
Organization Info
The Anthropic provider includes organization metadata:- ID:
anthropic - Name: Anthropic
- Website: https://anthropic.com
- Privacy: Data may be used for model training and abuse prevention
Advanced Options
You can pass additional options usingElElEmOptions: