Phase 13: Tools & Protocols

Function Calling Deep Dive — OpenAI, Anthropic, Gemini

The three frontier providers converged on the same tool-call loop in 2024 and then diverged on everything else. OpenAI uses tools and toolcalls. Anthropic uses tooluse and toolresult blocks. Gemini uses functionDeclarations and unique-id correlation. This lesson diffs the three side by side so code that ships on one provider does not break when you port it. State the three shape differences between OpenAI, Anthropic, and Gemini function-calling payloads (declaration, call, result). Translate one tool declaration across all three provider formats and predict where strict-mode constraints will differ. Use toolchoice in each provider to force, forbid, or auto-pick tool calls. Know the per-provider hard limits (tool count, schema depth, argument length) and the error signatures each one emits when limits are violated. The shape of a function-calling request differs by provider. Three concrete examples from 2026 production stacks: OpenAI Chat Completions / Responses API. You pass tools: [{type: "function", function: {name, description, parameters, strict}}]. The model's response contains choices[0].message.toolcalls: [{id, type: "function", function: {name, arguments}}] where arguments is a JSON string you must parse. Strict mode (strict: true) enforces schema compliance via constrained decoding. Anthropic Messages API. You pass tools: [{name, description, inputschema}]. The response comes back as content: [{type: "text"}, {type: "tooluse", id, name, input}]. input is already parsed (an object, not a string). You reply with a new…

Function Calling Deep Dive — OpenAI, Anthropic, Gemini: The three frontier providers converged on the same tool-call loop in 2024 and then diverged on…

This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.

Browse the complete course catalog or open this lesson on GitHub.