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

# Claude messages

> Use the Anthropic Messages-compatible endpoint.

<Warning>
  This is a compatibility endpoint for existing Anthropic-style integrations. For new integrations, use the [OpenAI-compatible API](/api-reference/chat-completions).
</Warning>

`POST https://api.freemodel.app/v1/messages`

Choose a Claude-compatible model ID returned by [`GET /v1/models`](/api-reference/list-models).

## Create a message

FreeModel accepts a standard Bearer key. Integrations that send an `x-api-key` header can also use a FreeModel `sk-...` key.

```bash theme={null}
curl https://api.freemodel.app/v1/messages \
  -H "Authorization: Bearer sk-xxxx" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "<claude-model-id>",
    "max_tokens": 128,
    "messages": [
      {
        "role": "user",
        "content": "Explain what an API gateway does in one sentence."
      }
    ]
  }'
```

```json Response theme={null}
{
  "id": "msg_01HXYZ",
  "type": "message",
  "role": "assistant",
  "model": "<claude-model-id>",
  "content": [
    {
      "type": "text",
      "text": "An API gateway gives clients one interface for routing requests to backend services."
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 12,
    "output_tokens": 15
  }
}
```

## Request body

| Field         | Type    | Required | Description                                              |
| ------------- | ------- | -------- | -------------------------------------------------------- |
| `model`       | string  | Yes      | A Claude-compatible model ID available to your key.      |
| `messages`    | array   | Yes      | Anthropic-style conversation messages.                   |
| `max_tokens`  | integer | Yes      | Maximum tokens to generate.                              |
| `stream`      | boolean | No       | Set to `true` when your client expects an event stream.  |
| `temperature` | number  | No       | Sampling variation when supported by the selected model. |

<Tip>
  With an Anthropic SDK, set its base URL to `https://api.freemodel.app`. See [Anthropic SDK](/sdks/anthropic-sdk).
</Tip>
