Skip to content

Anthropic Interaction Example

Back to Anthropic Messages.

This page mirrors the detailed Chinese interaction example in a compact English form. It is a protocol illustration, not a replayable upstream fixture.

The user asks whether Beijing is suitable for running today. The client exposes a local get_weather tool, while the upstream may use an Anthropic server-side web_search tool.

  1. 1
    client request

    Client sends `messages`, local `get_weather`, server `web_search`, and `stream: true`.

  2. 2
    provider pass-through

    ProxAI forwards the Anthropic Messages request to the configured upstream.

  3. 3
    first SSE turn

    Upstream emits server-tool use/result blocks and a local `tool_use(get_weather)` block.

  4. 4
    local tool runtime

    Client runs `get_weather` using the accumulated `input_json_delta` fragments.

  5. 5
    second request

    Client sends the previous assistant `tool_use` plus a user-side `tool_result`.

  6. 6
    final SSE answer

    Upstream emits text deltas and ends with `message_delta(stop_reason=end_turn)` plus `message_stop`.

IDSourceHow it is used later
srvu_01server_tool_useExecuted by the upstream service; the client does not send a matching tool result.
srvr_01web_search_tool_resultIdentifies the server-tool result block itself.
toolu_01tool_use(get_weather)Client executes the local tool and sends tool_result.tool_use_id = toolu_01 in the next request.

Anthropic streaming joins content deltas by content_block index:

content_blocks[index] = started block
partial_tool_inputs[index] += input_json_delta.partial_json

When content_block_stop(index=2) arrives, the client can parse the accumulated partial JSON and use the same block’s ToolUseBlock.id as the local tool call id.