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

# Messages

> Create a model response using the Anthropic Messages API format through the attested Confidential AI gateway.

Creates a model response using the Anthropic Messages request and response format. Requests are served through the attested gateway and return an `x-receipt-id` header for verification.

## Endpoint

```bash theme={"system"}
POST https://inference.phala.com/v1/messages
```

## Request Body

<ParamField body="model" type="string" required>
  Model id returned by [List Models](/phala-cloud/confidential-ai/confidential-model/api-reference/models).
</ParamField>

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

<ParamField body="messages" type="array" required>
  Conversation turns. Each item has a `role` (`user` or `assistant`) and `content`.
</ParamField>

<ParamField body="system" type="string">
  System prompt, sent as a top-level field.
</ParamField>

<ParamField body="temperature" type="number">
  Sampling temperature.
</ParamField>

<ParamField body="stream" type="boolean">
  Stream the response as server-sent events.
</ParamField>

<ParamField body="provider" type="object">
  Routing constraints for this request, applied together. `zdr` restricts routing to providers that do not retain content; `aci_verified` restricts it to an upstream verified inside the TEE; `aci_session_ids` pins it to specific attested channels.

  ```json theme={"system"}
  {"provider": {"aci_verified": true}}
  ```

  If no provider satisfies the constraints the request fails before the prompt is sent, and failover retries stay inside the allowed set. Field reference: [Chat Completions](/phala-cloud/confidential-ai/confidential-model/api-reference/chat-completions#body-provider). See [Attested Routing](/phala-cloud/confidential-ai/confidential-model/attested-routing) and [Zero Data Retention](/phala-cloud/confidential-ai/confidential-model/zero-data-retention).
</ParamField>

## Example

```bash theme={"system"}
curl https://inference.phala.com/v1/messages \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-4.5",
    "max_tokens": 100,
    "messages": [
      {"role": "user", "content": "Say hello in three words."}
    ]
  }'
```

## Response

```json theme={"system"}
{
  "id": "msg_01ABC...",
  "type": "message",
  "role": "assistant",
  "model": "anthropic/claude-sonnet-4.5",
  "content": [
    { "type": "text", "text": "Hello, howdy, hi!" }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": { "input_tokens": 14, "output_tokens": 8 }
}
```

Read assistant text from `content[].text` on blocks with `type: "text"`. `stop_reason` is usually `end_turn`, `max_tokens`, `stop_sequence`, or `tool_use`.

## Verification

Use the response `x-receipt-id` header with [Get Receipt](/phala-cloud/confidential-ai/confidential-model/api-reference/receipts). A confidential response has `upstream.verified.result = verified` and `required = true`.

## Related

<CardGroup cols={2}>
  <Card title="Responses" icon="arrow-right-arrow-left" href="/phala-cloud/confidential-ai/confidential-model/api-reference/responses" />

  <Card title="Trust Boundary" icon="shield-halved" href="/phala-cloud/confidential-ai/confidential-model/trust-boundary" />
</CardGroup>
