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

# Anthropic Messages API

> Send Claude message requests using the official Anthropic SDKs and cURL.

Neosantara provides complete protocol parity with the [Anthropic](https://www.anthropic.com/?utm_source=neosantara-docs\&utm_medium=referral) Messages API through `/anthropic/v1/messages`. You can use the official `@anthropic-ai/sdk` or Anthropic Python SDK without changing application logic.

```python Python icon="python" theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
from anthropic import Anthropic
import os

client = Anthropic(
    base_url="https://api.neosantara.xyz/anthropic",
    api_key=os.environ["NEOSANTARA_API_KEY"]
)

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[
        {"role": "user", "content": "Explain AI gateways in one concise paragraph."}
    ]
)

print(message.content[0].text)
```

```typescript TypeScript icon="js" theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://api.neosantara.xyz/anthropic",
  apiKey: process.env.NEOSANTARA_API_KEY,
});

const message = await client.messages.create({
  model: "claude-sonnet-4-6",
  max_tokens: 1024,
  messages: [
    { role: "user", content: "Explain AI gateways in one concise paragraph." },
  ],
});

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

```bash cURL icon="terminal" theme={"theme":{"light":"catppuccin-latte","dark":"ayu-dark"}}
curl -X POST https://api.neosantara.xyz/anthropic/v1/messages \
  -H "x-api-key: $NEOSANTARA_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Explain how an AI gateway works in one paragraph."}
    ]
  }'
```

## Required Headers

| Header | Value | Description |
| :- | :- | :- |
| `x-api-key` | `nsk_...` | Your Neosantara API key. |
| `anthropic-version` | `2023-06-01` | Anthropic API protocol version. |
| `Content-Type` | `application/json` | Request payload format. |

## Anthropic vs OpenAI Protocol Differences

| Concept | Anthropic Messages | OpenAI Chat Completions |
| :- | :- | :- |
| **System Prompt** | Top-level `system` parameter | Message item with `role: "system"` in `messages` |
| **Output Token Limit** | `max_tokens` is mandatory | `max_tokens` is optional (model default applies) |
| **Message Output** | Array of content objects: `content[0].text` | Single choice object: `choices[0].message.content` |
| **Base URL** | `https://api.neosantara.xyz/anthropic` | `https://api.neosantara.xyz/v1` |

## Advanced Features

| Feature | Guide |
| :- | :- |
| Streaming Claude responses | [Streaming Responses](https://docs.neosantara.xyz/en/gateway/anthropic-messages/streaming.md) |
| Anthropic tool use | [Anthropic Tool Use](https://docs.neosantara.xyz/en/gateway/anthropic-messages/tool-use.md) |
| Reasoning & extended thinking | [Extended Thinking](https://docs.neosantara.xyz/en/gateway/anthropic-messages/thinking.md) |
| Multimodal image input | [Anthropic Vision](https://docs.neosantara.xyz/en/gateway/anthropic-messages/vision.md) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.