# Messages

Send a conversation to a model that supports the Messages API.

## Endpoint

`POST https://mia-ai-proxy-sit.ambr.io/v1/messages`

For the Anthropic SDK and its `x-api-key` authentication, see [Native APIs](https://mia-ai-proxy-sit.ambr.io/docs/native-apis.md#anthropic-sdk).

## Request

Set `MIA_MODEL` to a Messages model ID from [Explore](https://mia-ai-proxy-sit.ambr.io/explore).

```bash
curl "https://mia-ai-proxy-sit.ambr.io/v1/messages" \
  -H "Authorization: Bearer $MIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"model\":\"$MIA_MODEL\",\"max_tokens\":256,\"messages\":[{\"role\":\"user\",\"content\":\"Hello\"}]}"
```

For a subsequent turn, preserve the complete assistant content, including tool use and thinking blocks.

## Fields

| Field | Type | Description |
| --- | --- | --- |
| `model` | string | Required. ID of a model that supports Messages. |
| `max_tokens` | integer | Required. Maximum number of tokens to generate. |
| `messages` | array | Required. Conversation messages with a `role` and `content`. |
| `stream` | boolean | Optional. Set to `true` to receive events as they are generated. |

## Sampling compatibility

On Claude targets that have removed sampling controls, legacy `temperature`,
`top_p` and `top_k` fields are accepted for compatibility but do not affect the
output. Supported older models retain them. No client migration is required
for requests that reach the gateway. If your request requires every supplied
parameter to take effect, use `provider.require_parameters: true`; a route
that cannot honor those parameters is not selected.

## Response

A non-streaming text response includes:

```json
{
  "type": "message",
  "role": "assistant",
  "content": [{"type": "text", "text": "Hello!"}],
  "stop_reason": "end_turn"
}
```

Fields and content vary by model and request.

## Streaming

Set `stream` to `true` to receive events as output is generated. See [Streaming](https://mia-ai-proxy-sit.ambr.io/docs/streaming.md).
