anthropic provider supports the Anthropic /v1/messages endpoint for Claude models.
Quick Start
Authentication
Set your Anthropic API key as an environment variable:Configuration Options
BAML-Specific Options
These options modify the API request sent to Anthropic.Passed as a bearer token in the Authorization header:
Authorization: Bearer $api_keyThe base URL for the Anthropic API.
Additional headers to send with requests.Unless specified, BAML injects this default header:Example:
Supported Models
The Claude model to use.
You can specify any model name - BAML won’t validate whether it exists.See the Anthropic documentation for the latest models.
| Model | Use Case | Release | Context | Features |
|---|---|---|---|---|
| claude-opus-4-1-20250805 | Complex coding, AI agents | Aug 2025 | 200K | Most powerful reasoning |
| claude-sonnet-4-20250514 | Default choice, versatile | May 2025 | 200K-1M | Hybrid reasoning modes |
| claude-3-5-haiku-20241022 | Fast, cost-efficient | Oct 2024 | 200K | Speed optimized |
Model Parameters
These parameters are passed directly to the Anthropic API.The maximum number of tokens to generate.
temperature- Controls randomness (0-1)max_tokens- Maximum tokens to generate (required by Anthropic)top_p- Nucleus sampling parametertop_k- Top-k sampling parameterstop_sequences- Array of sequences that stop generation
Media Handling
Anthropic’s default behavior converts PDFs to base64 (
send_base64) while keeping other media types as URLs (send_url). This is because Anthropic’s API requires PDFs to be base64-encoded.Features
- Streaming: Supported for real-time response generation
- Multimodal: Supports text, image, and PDF inputs
- Extended Thinking: Available with Opus-4 and Sonnet-4 models
- Tool Use: Native support for function calling
System Messages
BAML automatically constructs the
system field from your prompt if necessary. Only the first system message is used; subsequent ones are cast to the assistant role.Do Not Set
BAML automatically constructs this from your prompt.
BAML automatically constructs this from your prompt.
BAML automatically sets this based on how you call the client in your code.