AI Certifications Hub 2026

CCDV-F Domain 1: Messages API Fundamentals

Technical mechanics of the Anthropic Messages API (`/v1/messages`), request schemas, role alternations, parameter configuration, and token budgeting.

1. The `/v1/messages` Endpoint & Request Structure

All modern Claude interactions use the POST https://api.anthropic.com/v1/messages endpoint. Required request headers include:

  • x-api-key: Your Anthropic secret API key.
  • anthropic-version: Set to 2023-06-01.
  • content-type: application/json.

2. Core Request Payload Parameters

Parameter Type Description & Rules
model String (Required) Model ID, e.g. claude-3-5-sonnet-20241022 or claude-3-5-haiku-20241022.
max_tokens Integer (Required) Mandatory maximum tokens to generate. Anthropic requires this parameter on every call.
messages Array (Required) List of turn objects. Roles must alternate strictly between user and assistant.
system String / Array Top-level system instructions. Do not pass role: "system" inside the messages array.
temperature Float (0.0 to 1.0) Amount of randomness. Default is 1.0; set to 0.0 for deterministic extraction and code analysis.
stop_sequences Array of Strings Custom strings that cause the model to stop generating tokens when encountered.

3. Assistant Message Prefilling

You can steer Claude's output format by starting the assistant turn. The API will continue generating directly from that prefix:

{
  "model": "claude-3-5-sonnet-20241022",
  "max_tokens": 1024,
  "messages": [
    { "role": "user", "content": "Extract customer details from the email." },
    { "role": "assistant", "content": "{\n  \"customer_id\":" }
  ]
}

4. Understanding Stop Reasons

The response payload contains a stop_reason field that communicates how generation concluded:

  • end_turn: Model finished its complete natural response.
  • max_tokens: Generation was cut short because it hit the max_tokens limit.
  • stop_sequence: Generation stopped upon hitting one of your provided custom stop sequences.
  • tool_use: Model is requesting the execution of an external tool.