C.W.K.
Stream
Lesson 01 of 05 · published

Three Houses, One Idea

~22 min · openai, anthropic, gemini, compatibility

Level 0Curious Reader
0 XP0/48 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

OpenAI shipped tool calling in mid-2023; Anthropic followed with its own version a few months later; Google added function declarations to Gemini soon after. Within a year, the same essential idea — model returns a structured tool-call object instead of trying to write JSON in prose — had three production-ready implementations.

The good news is that the concept is identical across all three. You define tools, you call the model with them, you read tool-call objects back, you execute and feed results in. If you can write the loop on one provider you can write it on the other two with a few hours of envelope translation.

The bad news is in the envelope. OpenAI calls them tools with type: "function" and a parameters field; Anthropic calls them tools with input_schema; Gemini calls them FunctionDeclarations inside a Tool object. The flow is the same; the names are not.

This track is a tour of those three envelopes. The goal is not memorization — every SDK has docs and you will look them up — but to recognize what is the same idea wearing different clothes vs. what is a real provider-specific feature you cannot port. Knowing the difference saves you from copy-pasting yourself into the wrong abstraction.

Code

Side-by-side: defining one tool, three ways·python
# OpenAI (Responses API)
openai_tools = [{
    "type": "function",
    "name": "get_weather",
    "description": "Get current weather for a city.",
    "parameters": {
        "type": "object",
        "properties": {"location": {"type": "string"}},
        "required": ["location"],
    },
}]

# Anthropic
anthropic_tools = [{
    "name": "get_weather",
    "description": "Get current weather for a city.",
    "input_schema": {
        "type": "object",
        "properties": {"location": {"type": "string"}},
        "required": ["location"],
    },
}]

# Gemini (google-genai)
from google.genai import types
gemini_tools = [types.Tool(function_declarations=[types.FunctionDeclaration(
    name="get_weather",
    description="Get current weather for a city.",
    parameters=types.Schema(
        type=types.Type.OBJECT,
        properties={"location": types.Schema(type=types.Type.STRING)},
        required=["location"],
    ),
)])]

External links

Exercise

Pick one tool and write its definition for all three providers, side by side, in the same file. Run each through its provider's SDK validator (or just send a no-op call). Now you know which fields are the same and which need translation. Pin this file as your provider rosetta stone.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.