Messages API
POST /v1/messages — the Anthropic-format endpoint: parameters, response shape and examples.
The endpoint every Anthropic-compatible client uses, including Claude Code and the official SDKs.
Endpoint
POST https://aiprimetech.io/v1/messagesAuth
x-api-key: sk-...Version header
anthropic-version: 2023-06-01Content type
application/jsonRequest 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 |
metadata | object | no | Passed through; user_id is useful for your own attribution |
Example
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
{
"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
{
"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 — 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.