TokenPad
Building

Function Call Message Formatter

Build the tool_use and tool_result blocks by hand, correctly.

One call per line: tool | arguments JSON | result

98 characters1 lines0 tokensor drop a file

Function Call FormatterExact
0Token change
Token change0no change
Input tokens0what you pasted
Output tokens0what you would send
Token cost of this result
Output tokens0
As input$0.00
× 100K requests$0.00

Everything on this page runs in your browser. Nothing you paste is transmitted, because there is no server here to transmit it to.

Result
 

Where this is needed

Reproducing an agent bug, building a test fixture, or writing a few-shot example that includes a tool call. All three require hand-writing message blocks that frameworks normally generate, and the structure is fiddly.

The identifier linking a call to its result is the part most often got wrong. A mismatch produces an API error that names neither the call nor the result.

The provider difference

Anthropic represents calls as content blocks inside an assistant message, with results as blocks inside a following user message. OpenAI uses a tool_calls array on the assistant message and separate messages with role "tool".

They are different enough that porting by hand is unreliable, which is why both are generated from the same input here.

Frequently asked questions

Why must tool results come back in a specific message role?
Because the API models the exchange as a conversation. The result is input to the model, so it belongs on the message role that carries input — user for Anthropic, a dedicated tool role for OpenAI.
Do tool calls and results count as tokens?
Yes, all of it: the call arguments, the result content, and the tool definitions themselves. Tool results are frequently the largest part of an agent request and the least examined.

More building tools