Claudio.Messages.Response (Claudio v0.6.0)
View SourceStructured response from the Messages API.
Summary
Functions
Converts a raw API response map into a structured Response.
Aggregates every citation across all text blocks, in document order.
Extracts all MCP tool use requests from the response.
Extracts MCP tool use requests from the response for a specific server.
Extracts all server-side tool use requests (server_tool_use) from the
response — e.g. web_search / web_fetch invocations Claude ran on the
server. The matching results are web_search_tool_result blocks.
Extracts all text content from the response.
Extracts all tool use requests from the response.
Converts the response content into API-shaped assistant content blocks for replaying as the assistant turn in a follow-up request
Types
@type content_block() :: text_block() | thinking_block() | redacted_thinking_block() | tool_use_block() | tool_result_block() | mcp_tool_use_block() | mcp_tool_result_block() | server_tool_use_block() | web_search_tool_result_block()
@type redacted_thinking_block() :: %{type: :redacted_thinking, data: String.t()}
@type stop_reason() ::
:end_turn
| :max_tokens
| :stop_sequence
| :tool_use
| :pause_turn
| :refusal
| :model_context_window_exceeded
@type t() :: %Claudio.Messages.Response{ content: [content_block()], id: String.t(), model: String.t(), role: String.t(), stop_reason: stop_reason() | nil, stop_sequence: String.t() | nil, type: String.t(), usage: usage() }
Functions
Converts a raw API response map into a structured Response.
Aggregates every citation across all text blocks, in document order.
Each entry is the raw citation map as returned by the API (e.g.
char_location, page_location, content_block_location,
search_result_location, web_search_result_location). Returns [] when no
citations are present.
@spec get_mcp_tool_uses(t()) :: [mcp_tool_use_block()]
Extracts all MCP tool use requests from the response.
@spec get_mcp_tool_uses(t(), String.t()) :: [mcp_tool_use_block()]
Extracts MCP tool use requests from the response for a specific server.
@spec get_server_tool_uses(t()) :: [server_tool_use_block()]
Extracts all server-side tool use requests (server_tool_use) from the
response — e.g. web_search / web_fetch invocations Claude ran on the
server. The matching results are web_search_tool_result blocks.
Extracts all text content from the response.
@spec get_tool_uses(t()) :: [tool_use_block()]
Extracts all tool use requests from the response.
Converts the response content into API-shaped assistant content blocks for replaying as the assistant turn in a follow-up request:
request
|> Request.add_message(:assistant, Response.to_assistant_content(response))Emits string-keyed blocks that preserve signature (thinking) and data
(redacted_thinking) — both required by the API when continuing an
extended-thinking + tool-use conversation. Unknown block types are passed
through unchanged (coverage grows in later specs).