The Messages API (client.messages) is the primary interface for sending messages to Claude; it accepts a message array with optional system prompt, handles content shorthand and turn merging, and provides streaming and batch sub-resources. The API enforces practical limits (100k messages per request) and offers cache warming, inference geo-targeting, service tier selection, and deprecation warnings for older models.
The Messages resource (src/anthropic/resources/messages/messages.py) exposes a batches sub-resource accessible via client.messages.batches, plus streaming helpers via .with_streaming_response that don't eagerly read the response body.[1]
Messages.create enforces a hard limit of 100,000 messages in a single request.[1] A string value for content in a message is shorthand for an array containing one content block of type "text": {"role": "user", "content": "Hello"} is equivalent to {"role": "user", "content": [{"type": "text", "text": "Hello"}]}.[1] System prompts are passed as a top-level system parameter (a string or array of TextBlockParam); there is no "system" role for input messages in the Messages API.[1] Consecutive user or assistant turns in the messages parameter are automatically combined into a single turn by the model.[1] When the final message uses the assistant role, the response content continues immediately from that message's content, enabling prefilling and partial response constraining.[1] The top-level cache_control parameter automatically applies a cache_control marker to the last cacheable block in the request.[1] The service_tier parameter ("auto" or "standard_only") selects between priority capacity and standard capacity for a request.[1] The inference_geo parameter specifies the geographic region for inference processing; if omitted, the workspace's default_inference_geo is used.[1] In src/anthropic/resources/messages/batches.py, the GA (non-beta) message batch response wrapper classes — both raw and streaming — expose a results property for accessing batch result lines, matching the accessor already present on the beta wrapper.
The deprecated model list is exported from anthropic.resources.messages as DEPRECATED_MODELS; the streaming layer imports it to emit deprecation warnings — see MessageStream helpers for streaming-side behaviour.[2] Models claude-3-sonnet-20240229, claude-2.1, and claude-2.0 are marked deprecated as of July 21st, 2025; claude-3-opus-20240229 is marked deprecated as of January 5th, 2026.[1] claude-opus-4-0, claude-opus-4-20250514, claude-sonnet-4-0, and claude-sonnet-4-20250514 are marked deprecated as of June 15th, 2026.[1] The constant MODELS_TO_WARN_WITH_THINKING_ENABLED flags claude-opus-4-6 and claude-mythos-preview as models that emit a warning when extended thinking is enabled.[1]
Sources