anthropic.Client
One model turn against Anthropic's Messages API (`POST https://api.anthropic.com/v1/messages`).
Signature
class anthropic.ClientOne model turn against Anthropic's Messages API
(POST https://api.anthropic.com/v1/messages).
Construction reads no environment variable, so declaring a client is always safe; the credential resolves when a request is built.
Source:<builtin>/anthropic/messages.bamlbytes 2791–8576
Fields
model
stringapi_key
ai.Credential | nullbase_url
ai.Credential | nullrequest_timeout_ms
int | nulltime_to_first_token_timeout_ms
int | nullmax_tokens
inttemperature
float | nulltop_p
float | nulltop_k
int | nullstop_sequences
string[] | nullthinking
anthropic.ThinkingConfig | nulltool_choice
anthropic.ToolChoice | nullrequest_body
baml.json.json | nullheaders
map<string, string> | nullquery_params
map<string, string> | nullcapture_wire
boolStatic methods
new
(NOTE: the task spec named "claude-3-5-haiku-latest" as the default, but that model was retired (the API 404s on it); claude-haiku-4-5 is the current Haiku.
max_tokens defaults to 8192, not the engine's 4096 (PLAN §5): every model this client can address supports at least that, and 4096 silently truncates ordinary structured answers.
Instance methods
resolved_api_key
(The request-time credential: an explicit value, else the provider's canonical one.
A missing credential is a CATCHABLE configuration error, thrown the same
way the chat family reports one (_chat_headers): baml.env.get_or_panic
used to raise an uncatchable panic that escaped catch_all — so it
bypassed this client's own invoke normalize wrapper and turned the one
misconfiguration every deployment hits first into a process-level failure.
resolved_base_url
(self) -> string | null throws baml.errors.Io | baml.errors.ParseErrorThe request-time base URL, or null for the provider default.
Implementations
ai.Client for anthropic.Client
Instance methods
id
(self) -> stringinvoke
(render
(Source:<builtin>/anthropic/messages.bamlbytes 7728–8284
ai.stream.StreamingClient for anthropic.Client
Instance methods
invoke_stream
(Source:<builtin>/anthropic/messages.bamlbytes 8290–8574