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

# Create Message

> Interact with Anthropic's Messages API

**Endpoint:** `POST /messages`

Send a message to Claude via the Messages API.

<Note>
  Most integrations should use [Create Chat Completion](/api-reference/chat/create). Use this endpoint when you specifically need Anthropic's Messages request format.
</Note>

<CodeGroup>
  ```python Python theme={null}
  import os
  import requests

  response = requests.post(
      "https://api.yourouter.ai/v1/messages",
      headers={
          "Authorization": f"Bearer {os.environ['YOUROUTER_API_KEY']}",
          "Content-Type": "application/json",
          "anthropic-version": "2023-06-01",
          "vendor": "anthropic"
      },
      json={
          "model": "claude-3-5-sonnet-20240620",
          "messages": [{"role": "user", "content": "Hello"}]
      }
  )
  print(response.json())
  ```

  ```bash cURL theme={null}
  curl https://api.yourouter.ai/v1/messages \
    -H "Authorization: Bearer $YOUROUTER_API_KEY" \
    -H "Content-Type: application/json" \
    -H "anthropic-version: 2023-06-01" \
    -H "vendor: anthropic" \
    -d '{"model": "claude-3-5-sonnet-20240620", "messages": [{"role": "user", "content": "Hello"}]}'
  ```
</CodeGroup>

## Parameters

<ResponseField name="model" type="string" required>
  Target model ID.
</ResponseField>

<ResponseField name="messages" type="array" required>
  Conversation history in Claude's message format.
</ResponseField>

<ResponseField name="stream" type="boolean" default="false">
  If true, results are returned as server-sent events.
</ResponseField>

## Image Input

For Claude vision models, send image content blocks in the `messages` array.

```bash theme={null}
curl https://api.yourouter.ai/v1/messages \
  -H "Authorization: Bearer $YOUROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -H "vendor: anthropic" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 300,
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "Describe this image in one sentence." },
          {
            "type": "image",
            "source": {
              "type": "base64",
              "media_type": "image/jpeg",
              "data": "<BASE64_IMAGE>"
            }
          }
        ]
      }
    ]
  }'
```

## PDF Input

For Claude models that support PDFs, send a `document` content block and set `source.media_type` to `application/pdf`. The `data` field contains the base64-encoded raw PDF bytes.

```bash theme={null}
curl https://api.yourouter.ai/v1/messages \
  -H "Authorization: Bearer $YOUROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -H "vendor: anthropic" \
  -d '{
    "model": "claude-sonnet-4-20250514",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "document",
            "source": {
              "type": "base64",
              "media_type": "application/pdf",
              "data": "<BASE64_PDF>"
            }
          },
          {
            "type": "text",
            "text": "Summarize this PDF and list risks to watch."
          }
        ]
      }
    ]
  }'
```

<Note>
  Claude PDF support depends on the specific model. Use standard, unencrypted PDFs and control request body size and page count; split large documents into batches.
</Note>

See the [Multimodal guide](/guides/multimodal) for the broader integration path.
