> ## Documentation Index
> Fetch the complete documentation index at: https://docs.naga.ac/llms.txt
> Use this file to discover all available pages before exploring further.

# Messages API

> Anthropic-compatible messages endpoint for Claude-style integrations and agent tooling.

<Note>
  `Messages API` is a compatibility surface for Anthropic-style clients. For new
  LLM integrations without that requirement, prefer [Responses API](/api/responses).
</Note>

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](/api/responses).

## 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

<CodeGroup>
  ```python Python theme={null}
  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)
  ```

  ```javascript Node.js theme={null}
  import Anthropic from '@anthropic-ai/sdk';

  const client = new Anthropic({
    baseURL: 'https://api.naga.ac',
    apiKey: 'YOUR_API_KEY',
  });

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

  console.log(message.content[0].text);
  ```

  ```bash cURL theme={null}
  curl https://api.naga.ac/v1/messages \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "claude-sonnet-4.5",
      "max_tokens": 256,
      "messages": [
        {
          "role": "user",
          "content": [
            {"type": "text", "text": "Explain circuit breakers in simple terms."}
          ]
        }
      ]
    }'
  ```
</CodeGroup>

## Response Model

Successful responses follow the Anthropic message shape.

```json theme={null}
{
  "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

<CardGroup cols={2}>
  <Card title="Streaming" icon="signal" href="/api/messages/streaming">
    Handle Anthropic-style event streams and final usage data.
  </Card>

  <Card title="Tool Use" icon="wrench" href="/api/messages/tool-use">
    Work with `tool_use` and `tool_result` blocks.
  </Card>

  <Card title="Thinking Blocks" icon="brain" href="/api/messages/thinking-blocks">
    Understand reasoning controls and thinking block semantics.
  </Card>

  <Card title="Web Search" icon="search" href="/api/messages/web-search">
    Enable search-aware behavior in the Messages compatibility layer.
  </Card>

  <Card title="Documents and PDFs" icon="file-pdf" href="/api/messages/documents-and-pdfs">
    Send document blocks and PDF sources in Anthropic-style content.
  </Card>

  <Card title="Migration to Responses" icon="arrow-right-arrow-left" href="/api/messages/migration-to-responses">
    Move from Messages blocks to the Responses item model.
  </Card>
</CardGroup>

## Reference

* [Create message](/api-reference/endpoints/messages/create)
