Retrieve Message Batch results
$ ant messages:batches resultsStreams the results of a Message Batch as a .jsonl file.
Each line in the file is a JSON object containing the result of a single request in the Message Batch. Results are not guaranteed to be in the same order as requests. Use the custom_id field to match results to requests.
Learn more about the Message Batches API in our user guide
Returns
result: MessageBatchSucceededResult { message, type } or MessageBatchErroredResult { error, type } or MessageBatchCanceledResult { type } or MessageBatchExpiredResult { type }Processing result for this request.
Processing result for this request.
Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.
Content generated by the model.
Content generated by the model.
This is an array of content blocks, each of which has a type that determines its shape.
Example:
[{"type": "text", "text": "Hi, I'm Claude."}]If the request input messages ended with an assistant turn, then the response content will continue directly from that last turn. You can use this to constrain the model's output.
For example, if the input messages were:
[
{"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
{"role": "assistant", "content": "The best answer is ("}
]Then the response content might be:
[{"type": "text", "text": "B)"}]
Citations supporting the text block.
Citations supporting the text block.
The type of citation returned will depend on the type of document being cited. Citing a PDF results in page_location, plain text results in char_location, and content document results in content_block_location.
Always equals the contents of content[start_block_index:end_block_index] joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.
Always greater than start_block_index; a single-block citation has end_block_index = start_block_index + 1.
Always equals the contents of content[start_block_index:end_block_index] joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.
Always greater than start_block_index; a single-block citation has end_block_index = start_block_index + 1.
Counted separately from document_index; server-side web search results are not included in this count.
This is an opaque field and should not be interpreted or parsed. When passing thinking blocks back to the API (required when using tools with extended thinking), pass them back exactly as received, with this field intact.
See extended thinking for details.
Pass redacted_thinking blocks back to the API unchanged when continuing a multi-turn conversation.
See extended thinking for details.
caller: DirectCaller { type } or ServerToolCaller { tool_id, type } or ServerToolCaller20260120 { tool_id, type }Tool invocation directly from the model.
Tool invocation directly from the model.
caller: DirectCaller { type } or ServerToolCaller { tool_id, type } or ServerToolCaller20260120 { tool_id, type }Tool invocation directly from the model.
Tool invocation directly from the model.
caller: DirectCaller { type } or ServerToolCaller { tool_id, type } or ServerToolCaller20260120 { tool_id, type }Tool invocation directly from the model.
Tool invocation directly from the model.
content: WebSearchToolResultError { error_code, type } or array of WebSearchResultBlock { encrypted_content, page_age, title, 2 more }
caller: DirectCaller { type } or ServerToolCaller { tool_id, type } or ServerToolCaller20260120 { tool_id, type }Tool invocation directly from the model.
Tool invocation directly from the model.
content: WebFetchToolResultErrorBlock { error_code, type } or WebFetchBlock { content, retrieved_at, type, url }
content: CodeExecutionToolResultError { error_code, type } or CodeExecutionResultBlock { content, return_code, stderr, 2 more } or EncryptedCodeExecutionResultBlock { content, encrypted_stdout, return_code, 2 more }Code execution result with encrypted stdout for PFC + web_search results.
Code execution result with encrypted stdout for PFC + web_search results.
content: BashCodeExecutionToolResultError { error_code, type } or BashCodeExecutionResultBlock { content, return_code, stderr, 2 more }
content: TextEditorCodeExecutionToolResultError { error_code, error_message, type } or TextEditorCodeExecutionViewResultBlock { content, file_type, num_lines, 3 more } or TextEditorCodeExecutionCreateResultBlock { is_file_update, type } or TextEditorCodeExecutionStrReplaceResultBlock { lines, new_lines, new_start, 3 more }
content: ToolSearchToolResultError { error_code, error_message, type } or ToolSearchToolSearchResultBlock { tool_references, type }
The request could enable cyber harm, such as malware or exploit development. Benign cybersecurity work can also trigger this category.
The request could enable biological harm, such as dangerous lab methods. Beneficial life sciences work can also trigger this category.
The request could assist the development of competing AI models, which is restricted under Anthropic's commercial terms. Benign machine learning work can also trigger this category.
The request asks the model to reproduce its internal reasoning in the response text. To get reasoning in a structured form instead, use adaptive thinking.
This may be one the following values:
"end_turn": the model reached a natural stopping point"max_tokens": we exceeded the requestedmax_tokensor the model's maximum"stop_sequence": one of your provided customstop_sequenceswas generated"tool_use": the model invoked one or more tools"pause_turn": we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue."refusal": when streaming classifiers intervene to handle potential policy violations"model_context_window_exceeded": we exceeded the model's context window
In non-streaming mode this value is always non-null. In streaming mode, it is null in the message_start event and non-null otherwise.
Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.
Under the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in usage will not match one-to-one with the exact visible content of an API request or response.
For example, output_tokens will be non-zero, even for an empty string response from Claude.
Total input tokens in a request is the summation of input_tokens, cache_creation_input_tokens, and cache_read_input_tokens.
output_tokens remains the inclusive, authoritative total used for billing.
This object provides a read-only decomposition for observability — for example,
how many of the billed output tokens were spent on internal reasoning that may
have been summarized before being returned to you.
Reflects the raw reasoning the model produced, not the (possibly shorter)
summarized thinking text returned in the response body. Computed by
re-tokenizing the raw reasoning text, so it may differ from the model's exact
generation count by a small number of tokens. Always ≤ output_tokens;
output_tokens - thinking_tokens approximates the non-reasoning output.
error: InvalidRequestError { message, type } or AuthenticationError { message, type } or BillingError { message, type } or 6 more
Retrieve Message Batch results
ant messages:batches results \
--api-key my-anthropic-api-key \
--message-batch-id message_batch_id