HomeLearnCoursesHackathonsAccount
Hands-On AI Agent Development
Building With Claude, GPT, and Grok · 1/2

The same idea, three different shapes

observethinkact

The tool-calling pattern from the last lesson, describe your tools, let the model request one, execute it yourself, feed the result back, is universal, but the exact wire format for doing it differs by provider, so code written against one provider's shape isn't automatically portable to another. In Anthropic's Claude API, each tool is described with a name, a description, and an input_schema (a JSON Schema defining its accepted parameters). When Claude decides to call one, its response includes a tool_use content block containing the tool's name and a filled-in input object, and you continue the conversation by sending back a tool_result block tied to that same call's id.

OpenAI's GPT models describe tools as function objects with a name, a description, and a parameters field (also JSON Schema). When GPT wants to call one, the response includes a tool_calls array, where each entry names the function and supplies its arguments as a JSON-encoded string that your code has to parse. You respond with a new message whose role is 'tool', linked back to the original request via a tool_call_id. xAI's Grok was deliberately built to be API-compatible with this same tools and tool_calls shape, so code written against GPT's function-calling convention will very often work against Grok with only small adjustments, though it remains a distinct, separately evolving API, not a guaranteed permanent match.