Skip to main content
Messages API is a compatibility surface for Anthropic-style clients. For new LLM integrations without that requirement, prefer Responses API.
Use this API when your tooling already expects Anthropic-style content blocks, tool use blocks, and Messages streaming events. If you are starting a new integration and do not need Anthropic compatibility, use Responses API.

Best Fit

  • Anthropic-compatible SDKs and wrappers
  • agent frameworks that already target the Messages protocol
  • applications built around block-typed content instead of plain assistant strings

When to stay on Messages

  • your SDK or agent stack already depends on Anthropic block semantics
  • you need tool_use, tool_result, and thinking blocks in their Anthropic-style form
  • migration cost is higher than the benefit of switching to Responses right now

Request Model

Common fields include:
  • model
  • max_tokens
  • messages
  • system
  • tools
  • thinking
  • output_config
  • stream

Quick Example

from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.naga.ac",
    api_key="YOUR_API_KEY",
)

message = client.messages.create(
    model="claude-sonnet-4.5",
    max_tokens=256,
    messages=[
        {
            "role": "user",
            "content": "Explain circuit breakers in simple terms.",
        }
    ],
)

print(message.content[0].text)

Response Model

Successful responses follow the Anthropic message shape.
{
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Circuit breakers stop repeated failing calls so the rest of the system can recover."
    }
  ],
  "stop_reason": "end_turn"
}

Common mistakes

  • starting a new project on Messages when Anthropic compatibility is not required
  • assuming Messages blocks map 1:1 to Responses items without adaptation
  • forgetting that this is a compatibility surface over the same underlying platform

Learn The API In Detail

Streaming

Handle Anthropic-style event streams and final usage data.

Tool Use

Work with tool_use and tool_result blocks.

Thinking Blocks

Understand reasoning controls and thinking block semantics.

Web Search

Enable search-aware behavior in the Messages compatibility layer.

Documents and PDFs

Send document blocks and PDF sources in Anthropic-style content.

Migration to Responses

Move from Messages blocks to the Responses item model.

Reference