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

# Messages API

> Send requests using the Anthropic Messages API format for Claude models

The Messages API (`/v1/messages`) provides direct compatibility with the [Anthropic Messages API](https://docs.anthropic.com/en/api/messages) format. Use this endpoint when working with Anthropic Claude models and features like interleaved thinking, tool calling, and multi-turn conversations.

<Warning>
  The Messages API (`/v1/messages`) is fully supported on the **Enterprise plan** using `https://enterprise.blackbox.ai`. On standard plans (`https://api.blackbox.ai`), this endpoint may not work as expected. For the best experience, use an Enterprise API key.
</Warning>

## Basic Request

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import os
  import requests

  response = requests.post(
      'https://enterprise.blackbox.ai/v1/messages',
      headers={
          'Content-Type': 'application/json',
          'Authorization': f"Bearer {os.environ['BLACKBOX_API_KEY']}",
          'anthropic-version': '2023-06-01',
      },
      json={
          'model': 'blackboxai/anthropic/claude-sonnet-4.5',
          'max_tokens': 1024,
          'messages': [
              {'role': 'user', 'content': 'What is the capital of France?'}
          ],
      },
  )

  result = response.json()
  print(result['content'][0]['text'])
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  const response = await fetch("https://enterprise.blackbox.ai/v1/messages", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
      "anthropic-version": "2023-06-01"
    },
    body: JSON.stringify({
      model: "blackboxai/anthropic/claude-sonnet-4.5",
      max_tokens: 1024,
      messages: [
        { role: "user", content: "What is the capital of France?" }
      ]
    })
  });

  const result = await response.json();
  console.log(result.content[0].text);
  ```

  ```bash cURL theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  curl https://enterprise.blackbox.ai/v1/messages \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -H "anthropic-version: 2023-06-01" \
    -d '{
      "model": "blackboxai/anthropic/claude-sonnet-4.5",
      "max_tokens": 1024,
      "messages": [
        {"role": "user", "content": "What is the capital of France?"}
      ]
    }'
  ```
</CodeGroup>

## Response Format

```json theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "id": "gen_01KJRNETDECKXVWK0YX46WSHDY",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "The capital of France is Paris."
    }
  ],
  "model": "blackboxai/anthropic/claude-sonnet-4.5",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 19,
    "output_tokens": 10,
    "total_tokens": 29,
    "cache_read_input_tokens": 0,
    "cache_creation_input_tokens": 0
  }
}
```

***

## System Prompt

Use the `system` parameter to set the model's behavior for the entire conversation.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import os
  import requests

  response = requests.post(
      'https://enterprise.blackbox.ai/v1/messages',
      headers={
          'Content-Type': 'application/json',
          'Authorization': f"Bearer {os.environ['BLACKBOX_API_KEY']}",
          'anthropic-version': '2023-06-01',
      },
      json={
          'model': 'blackboxai/anthropic/claude-sonnet-4.5',
          'max_tokens': 256,
          'system': 'You are a helpful pirate. Always respond in pirate speak.',
          'messages': [
              {'role': 'user', 'content': 'What is 2 + 2?'}
          ],
      },
  )

  result = response.json()
  print(result['content'][0]['text'])
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  const response = await fetch("https://enterprise.blackbox.ai/v1/messages", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
      "anthropic-version": "2023-06-01"
    },
    body: JSON.stringify({
      model: "blackboxai/anthropic/claude-sonnet-4.5",
      max_tokens: 256,
      system: "You are a helpful pirate. Always respond in pirate speak.",
      messages: [
        { role: "user", content: "What is 2 + 2?" }
      ]
    })
  });

  const result = await response.json();
  console.log(result.content[0].text);
  ```

  ```bash cURL theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  curl https://enterprise.blackbox.ai/v1/messages \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -H "anthropic-version: 2023-06-01" \
    -d '{
      "model": "blackboxai/anthropic/claude-sonnet-4.5",
      "max_tokens": 256,
      "system": "You are a helpful pirate. Always respond in pirate speak.",
      "messages": [
        {"role": "user", "content": "What is 2 + 2?"}
      ]
    }'
  ```
</CodeGroup>

```json Response theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "id": "gen_01KJRNEX4M6JD4GDPF4K5MK2J0",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Arrr, that be an easy bit o' mathematics, matey! 2 + 2 equals 4, as sure as the seven seas be salty!"
    }
  ],
  "model": "blackboxai/anthropic/claude-sonnet-4.5",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 30,
    "output_tokens": 60
  }
}
```

***

## Multi-Turn Conversations

Pass previous messages as an array of alternating `user` and `assistant` messages to maintain conversation context.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  import os
  import requests

  response = requests.post(
      'https://enterprise.blackbox.ai/v1/messages',
      headers={
          'Content-Type': 'application/json',
          'Authorization': f"Bearer {os.environ['BLACKBOX_API_KEY']}",
          'anthropic-version': '2023-06-01',
      },
      json={
          'model': 'blackboxai/anthropic/claude-sonnet-4.5',
          'max_tokens': 256,
          'messages': [
              {'role': 'user', 'content': 'My name is Alice.'},
              {'role': 'assistant', 'content': 'Nice to meet you, Alice! How can I help you today?'},
              {'role': 'user', 'content': "What's my name?"},
          ],
      },
  )

  result = response.json()
  print(result['content'][0]['text'])
  ```

  ```typescript TypeScript theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  const response = await fetch("https://enterprise.blackbox.ai/v1/messages", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json",
      "anthropic-version": "2023-06-01"
    },
    body: JSON.stringify({
      model: "blackboxai/anthropic/claude-sonnet-4.5",
      max_tokens: 256,
      messages: [
        { role: "user", content: "My name is Alice." },
        { role: "assistant", content: "Nice to meet you, Alice! How can I help you today?" },
        { role: "user", content: "What's my name?" }
      ]
    })
  });

  const result = await response.json();
  console.log(result.content[0].text);
  ```

  ```bash cURL theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
  curl https://enterprise.blackbox.ai/v1/messages \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -H "anthropic-version: 2023-06-01" \
    -d '{
      "model": "blackboxai/anthropic/claude-sonnet-4.5",
      "max_tokens": 256,
      "messages": [
        {"role": "user", "content": "My name is Alice."},
        {"role": "assistant", "content": "Nice to meet you, Alice! How can I help you today?"},
        {"role": "user", "content": "What is my name?"}
      ]
    }'
  ```
</CodeGroup>

```json Response theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{
  "id": "gen_01KJRNF1RP8DWKJ3M59JDAQRHX",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Your name is Alice, as you just told me."
    }
  ],
  "model": "blackboxai/anthropic/claude-sonnet-4.5",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 37,
    "output_tokens": 14
  }
}
```

***

## Request Headers

<ParamField header="Authorization" type="string" required>
  API Key in the format `Bearer <api_key>`. Get yours from [here](https://app.blackbox.ai/dashboard).
</ParamField>

<ParamField header="anthropic-version" type="string" required>
  Anthropic API version. Use `2023-06-01`.
</ParamField>

<ParamField header="anthropic-beta" type="string">
  Optional beta features. For example, `interleaved-thinking-2025-05-14` for legacy interleaved thinking support.
</ParamField>

## Request Parameters

<ParamField body="model" type="string" required>
  The model ID. Supported models include:

  * `blackboxai/anthropic/claude-opus-4.8`
  * `blackboxai/anthropic/claude-opus-4.7`
  * `blackboxai/anthropic/claude-opus-4.6`
  * `blackboxai/anthropic/claude-opus-4.5`
  * `blackboxai/anthropic/claude-sonnet-4.6`
  * `blackboxai/anthropic/claude-sonnet-4.5`
</ParamField>

<ParamField body="max_tokens" type="integer" required>
  Maximum number of tokens to generate.
</ParamField>

<ParamField body="messages" type="array" required>
  Array of message objects with `role` (`user` or `assistant`) and `content` fields.
</ParamField>

<ParamField body="system" type="string">
  System prompt for the conversation.
</ParamField>

<ParamField body="tools" type="array">
  Array of tool definitions using the Anthropic `input_schema` format. See [Tool Calling](/api-reference/messages/tool-calling).
</ParamField>

<ParamField body="thinking" type="object">
  Configuration for extended / interleaved thinking. See [Interleaved Thinking](/api-reference/messages/interleaved-thinking).
</ParamField>

## Response Fields

<ResponseField name="id" type="string">
  Unique message identifier.
</ResponseField>

<ResponseField name="type" type="string">
  Always `"message"`.
</ResponseField>

<ResponseField name="role" type="string">
  Always `"assistant"`.
</ResponseField>

<ResponseField name="content" type="array">
  Array of content blocks. Each block has a `type` field:

  * `text` — Text response with a `text` field
  * `tool_use` — Tool call with `id`, `name`, and `input` fields
  * `thinking` — Thinking block with a `thinking` field (when thinking is enabled)
</ResponseField>

<ResponseField name="stop_reason" type="string">
  Why the model stopped generating:

  * `end_turn` — Natural completion
  * `tool_use` — Model wants to call a tool
  * `max_tokens` — Hit the token limit
</ResponseField>

<ResponseField name="usage" type="object">
  Token usage with `input_tokens` and `output_tokens`.
</ResponseField>

## Supported Models

| Model             | Model ID                                 | Tool Calling | Interleaved Thinking |
| ----------------- | ---------------------------------------- | :----------: | :------------------: |
| Claude Opus 4.6   | `blackboxai/anthropic/claude-opus-4.6`   |       ✓      |           ✓          |
| Claude Opus 4.5   | `blackboxai/anthropic/claude-opus-4.5`   |       ✓      |           ✓          |
| Claude Sonnet 4.6 | `blackboxai/anthropic/claude-sonnet-4.6` |       ✓      |           ✓          |
| Claude Sonnet 4.5 | `blackboxai/anthropic/claude-sonnet-4.5` |       ✓      |           ✓          |

<CardGroup cols={2}>
  <Card title="Tool Calling" icon="wrench" href="/api-reference/messages/tool-calling">
    Define tools and build multi-turn agentic loops
  </Card>

  <Card title="Interleaved Thinking" icon="brain" href="/api-reference/messages/interleaved-thinking">
    Enable reasoning between tool calls
  </Card>
</CardGroup>
