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

# Create Message

> Anthropic-compatible Messages endpoint. Supports OpenAI-style messages as input and can return OpenAI-style responses when response_format='openai' is provided.

Anthropic-compatible Messages endpoint.

Supports OpenAI-style messages as input and can return OpenAI-style responses
when `response_format='openai'` is provided.

### Request body

`MessagesRequest`

<ParamField body="model" type="string" required>
  Model identifier
</ParamField>

<ParamField body="messages" type="MessageInput[]" required>
  Conversation messages
</ParamField>

<ParamField body="system" type="string">
  System prompt (string or content blocks)
</ParamField>

<ParamField body="max_tokens" type="integer,null">
  Maximum tokens to generate
</ParamField>

<ParamField body="temperature" type="number,null">
  Sampling temperature
</ParamField>

<ParamField body="top_p" type="number,null">
  Top-p
</ParamField>

<ParamField body="top_k" type="integer,null">
  Top-k
</ParamField>

<ParamField body="stop_sequences" type="string[],null">
  Stop sequences (Anthropic style)
</ParamField>

<ParamField body="stream" type="boolean">
  Stream response tokens
</ParamField>

<ParamField body="tools" type="object[],null">
  Tool definitions (Anthropic or OpenAI format)
</ParamField>

<ParamField body="tool_choice" type="string">
  Tool choice configuration
</ParamField>

<ParamField body="metadata" type="object,null">
  Arbitrary metadata
</ParamField>

<ParamField body="response_format" type="string,null">
  Response format preference
</ParamField>

### Response

`MessagesResponse`

<ResponseField name="id" type="string" required>
  Message identifier
</ResponseField>

<ResponseField name="type" type="string">
  Response type
</ResponseField>

<ResponseField name="role" type="string">
  Assistant role
</ResponseField>

<ResponseField name="model" type="string" required>
  Model identifier
</ResponseField>

<ResponseField name="content" type="object[]" required>
  Response content blocks
</ResponseField>

<ResponseField name="stop_reason" type="string,null">
  Stop reason
</ResponseField>

<ResponseField name="stop_sequence" type="string,null">
  Stop sequence
</ResponseField>

<ResponseField name="usage" type="UsageInfo" required>
  Token usage

  <Expandable title="UsageInfo">
    <ResponseField name="input_tokens" type="integer" required>
      Prompt tokens used
    </ResponseField>

    <ResponseField name="output_tokens" type="integer" required>
      Completion tokens used
    </ResponseField>
  </Expandable>
</ResponseField>

### Status codes

| Code  | Meaning                                                                                                                                                  |
| ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200` | Anthropic-shaped reply. With `response_format: 'openai'` the body is an OpenAI chat completion instead; with `stream: true` it is a `text/event-stream`. |
| `401` | Authentication required                                                                                                                                  |
| `422` | Validation Error                                                                                                                                         |
| `429` | Rate limit exceeded                                                                                                                                      |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'http://localhost:8000/v1/messages' \
    --header 'Authorization: Bearer YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "model": "string",
    "messages": [
      {
        "role": "system",
        "content": "Two-person tent, green — replacement for damaged pole set.",
        "name": "Two-Person Tent",
        "tool_call_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "tool_calls": []
      }
    ],
    "system": "string",
    "max_tokens": 1,
    "temperature": 1.5,
    "top_p": 1.5,
    "top_k": 1,
    "stop_sequences": [
      "string"
    ],
    "stream": false,
    "tools": [
      {}
    ],
    "tool_choice": "string",
    "metadata": {},
    "response_format": "anthropic"
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "type": "message",
    "role": "assistant",
    "model": "string",
    "content": [
      {}
    ],
    "stop_reason": "string",
    "stop_sequence": "string",
    "usage": {
      "input_tokens": 1,
      "output_tokens": 1
    }
  }
  ```
</ResponseExample>
