Home / Docs / Your first request explained

Your first request explained

A line-by-line walkthrough of one Messages call — what every field does and what comes back.

The Quickstart gets you a response. This page explains what each part of it means, so the next request is one you write yourself.

The request

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"}]
  }'
FieldRequiredWhat it does
modelyesWhich model to run. Must match an id from /v1/models exactly.
max_tokensyesHard ceiling on the output. The model stops here even mid-sentence. This is a cost control, not a target.
messagesyesThe conversation so far, oldest first. Each entry has a role (user or assistant) and content.
systemnoInstructions that apply to the whole conversation. A top-level field, not a message with role: system.
temperatureno0–1. Lower is more deterministic. Leave unset unless you have a reason.
streamnotrue returns server-sent events instead of one JSON body. See Streaming.

The response

{
  "id": "msg_01ABC...",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-6",
  "content": [{"type": "text", "text": "Hello! How can I help?"}],
  "stop_reason": "end_turn",
  "usage": {"input_tokens": 9, "output_tokens": 12}
}
If stop_reason is max_tokens, your answer was cut off. Raise max_tokens or ask for a shorter reply — do not retry blindly, you pay for the truncated output too.

Multi-turn conversations

The API is stateless. To continue a conversation you resend the whole history, including the model's previous replies:

{
  "model": "claude-sonnet-4-6",
  "max_tokens": 1024,
  "messages": [
    {"role": "user", "content": "What is the capital of France?"},
    {"role": "assistant", "content": "Paris."},
    {"role": "user", "content": "And its population?"}
  ]
}
Because history is resent every turn, input tokens grow with the conversation and so does the bill. This is why long agent sessions get expensive. Prompt caching and context management both attack this directly.