AI & LLM

Anthropic Claude Messages Response JSON Example

A JSON example of an Anthropic Claude Messages API response — includes content blocks, stop_reason, and input/output token usage. Copy-ready for building apps on Claude.

{
  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-6",
  "content": [
    {
      "type": "text",
      "text": "A JSON Schema is a declarative way to describe the shape of a JSON document — which fields exist, their types, and what's required — so you can validate data automatically."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 19,
    "output_tokens": 38,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0
  }
}

Field Reference

idrequiredstringUnique message identifier, prefixed with msg_
typerequiredstringObject type — always 'message' for a Messages response
rolerequiredstringAlways 'assistant' for a response message
contentrequiredarray<object>Ordered content blocks; each has a type such as 'text' or 'tool_use'
stop_reasonrequiredstringWhy Claude stopped: end_turn, max_tokens, stop_sequence, or tool_use
usage.input_tokensrequiredintegerTokens counted for the prompt (messages + system)
usage.output_tokensrequiredintegerTokens generated in the response

Variants

Request bodyThe body you POST to /v1/messages.
{
  "model": "claude-sonnet-4-6",
  "max_tokens": 1024,
  "system": "You are a helpful, concise assistant.",
  "messages": [
    {
      "role": "user",
      "content": "Explain JSON Schema in one sentence."
    }
  ]
}
Tool use responseClaude returns a tool_use block when it wants to call one of your tools.
{
  "id": "msg_01Abc2Def3Ghi4Jkl5Mno6",
  "type": "message",
  "role": "assistant",
  "model": "claude-sonnet-4-6",
  "content": [
    {
      "type": "text",
      "text": "Let me look up that order."
    },
    {
      "type": "tool_use",
      "id": "toolu_01A09q90qw90lq917835lq9",
      "name": "get_order",
      "input": {
        "order_id": "ord_77F2K9"
      }
    }
  ],
  "stop_reason": "tool_use",
  "usage": {
    "input_tokens": 142,
    "output_tokens": 57
  }
}

Common Use Cases

  • Parsing Claude's response content blocks in a chat application
  • Detecting tool_use blocks to run agentic tool-calling loops
  • Tracking input/output and cache token usage for cost analysis
anthropicclaudellmmessages apiai api

Validate or format this JSON

One click loads this exact example into the tool — no copy-paste needed. Format it, validate it, explore the tree, or generate TypeScript types instantly.

Frequently Asked Questions

Claude can return multiple ordered blocks in one response — for example a text block followed by a tool_use block, or multiple text and image blocks. Iterate the array and handle each block by its 'type' rather than assuming a single string.

When stop_reason is 'tool_use', run the requested tool, then send a new user message containing a tool_result block that references the original tool_use id. Claude uses that result to produce its final answer.

They count prompt tokens served from prompt caching. Cached reads are billed at a large discount, so a high cache_read value with a low cache_creation value means your caching is working and saving money.

Related JSON Examples