Skip to main content

Anthropic

The anthropic provider supports the Anthropic /v1/messages endpoint.

Basic Example​

client<llm> MyClient {
provider anthropic
options {
model "claude-sonnet-4-20250514"
temperature 0
}
}

BAML-Specific Options​

OptionTypeDefaultDescription
api_keystringenv.ANTHROPIC_API_KEYAPI key for Authorization header
base_urlstringhttps://api.anthropic.comBase URL for API
headersobject-Additional request headers

Default Headers​

BAML automatically injects:

anthropic-version: 2023-06-01

Custom Headers​

client<llm> MyClient {
provider anthropic
options {
api_key env.MY_ANTHROPIC_KEY
model "claude-sonnet-4-20250514"
headers {
"X-My-Header" "my-value"
}
}
}

Available Models​

ModelUse CaseReleaseContext
claude-opus-4-1-20250805Complex coding, AI agentsAug 2025200K
claude-sonnet-4-20250514Default choice, versatileMay 2025200K-1M
claude-3-5-haiku-20241022Fast, cost-efficientOct 2024200K

See Anthropic Models for the complete list.

Provider Parameters​

OptionTypeDefaultDescription
modelstring-Model identifier
max_tokensint4096Maximum response tokens
temperaturefloat-Sampling temperature
top_pfloat-Nucleus sampling
top_kint-Top-k sampling
note

Anthropic's default behavior converts PDFs to base64 while keeping other media types as URLs, since the API requires PDFs to be base64-encoded.

See the Anthropic API documentation for all options.

See Also​