# Messages API > POST /v1/messages — the Anthropic-format endpoint: parameters, response shape and examples. _Source: https://aiprimetech.io/docs/api-reference/messages/ · Home > Docs > API reference_ The endpoint every Anthropic-compatible client uses, including Claude Code and the official SDKs. - **Endpoint:** `POST https://aiprimetech.io/v1/messages` - **Auth:** `x-api-key: sk-...` - **Version header:** `anthropic-version: 2023-06-01` - **Content type:** `application/json` ## Request body | Field | Type | Required | Description | |---|---|---|---| | `model` | string | yes | Model id, exactly as listed by `/v1/models` | | `messages` | array | yes | Alternating user / assistant turns, oldest first | | `max_tokens` | integer | yes | Maximum output tokens. Generation stops here. | | `system` | string or array | no | Top-level system prompt. Not a message role. | | `temperature` | number | no | 0–1. Omit for the model default. | | `top_p` | number | no | Nucleus sampling. Use this or temperature, not both. | | `stop_sequences` | array | no | Strings that halt generation when produced | | `stream` | boolean | no | true for server-sent events | | `tools` | array | no | Tool definitions — see [Tool use](/docs/api-reference/tool-use/) | | `metadata` | object | no | Passed through; `user_id` is useful for your own attribution | ## Example ```bash curl https://aiprimetech.io/v1/messages \ -H "x-api-key: $CLAUDEAPIKEY" \ -H "anthropic-version: 2023-06-01" \ -H "content-type: application/json" \ -d '{ "model": "claude-sonnet-4-6", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello"}] }' ``` ## Response ```json { "id": "msg_01ABC...", "type": "message", "role": "assistant", "model": "claude-sonnet-4-6", "content": [{"type": "text", "text": "..."}], "stop_reason": "end_turn", "stop_sequence": null, "usage": {"input_tokens": 9, "output_tokens": 12} } ``` | Field | Description | |---|---| | `content` | Array of blocks. Text blocks carry `type: text` and a `text` field; tool calls carry `type: tool_use`. | | `stop_reason` | `end_turn`, `max_tokens`, `stop_sequence` or `tool_use` | | `usage.input_tokens` | Billed input, including the full resent history | | `usage.output_tokens` | Billed output — typically 4–5× the input rate | ## System prompts ```json { "model": "claude-sonnet-4-6", "max_tokens": 1024, "system": "You are a terse assistant. Answer in at most two sentences.", "messages": [{"role": "user", "content": "Explain HTTP caching."}] } ``` > A stable `system` block is the ideal target for [prompt caching](/docs/guides/prompt-caching/) — it is identical on every call, so it can be read from cache at a fraction of the input price. ## Multimodal input Image blocks use the standard Anthropic shape — see [Vision](/docs/api-reference/vision/). - [Streaming](https://aiprimetech.io/docs/api-reference/streaming/) — Token-by-token output - [Tool use](https://aiprimetech.io/docs/api-reference/tool-use/) — Function calling - [Errors](https://aiprimetech.io/docs/api-reference/errors/) — Failure modes --- _ClaudeAPIKey.dev is an independently operated, Anthropic-compatible API gateway. Not affiliated with Anthropic._