⚠️ Pending Update · 2026-08-29 Verification · Content may be outdated, please refer to official docs Updated: 2026-08-29 · Status: Pending Verification
Background
OpenAI uses tools + tool_calls + function as three layers; Anthropic uses tools + tool_use block + tool_result pairing; Gemini uses function_declarations + functionCall + functionResponse. For the same agent code to run across models, the gateway must translate all three into one shape.
Unified Abstraction
- Input normalization: the client sends
toolsin OpenAI shape; the gateway translates to each vendor's native format. - Output normalization: Anthropic's
tool_useblock and Gemini'sfunctionCallboth become OpenAI'stool_callsarray. - Multi-turn normalization: regardless of vendor, the second-turn
toolrole message is translated into the corresponding vendor's "tool result" format (Anthropictool_result, GeminifunctionResponse). - Degradation for tool-less models: models like
llama-3.1-8bthat lack native tools can be "simulated" by the gateway via prompt injection + JSON parsing, at the cost of lower accuracy.
Code Example
def openai_tools_to_anthropic(tools):
return [{
"name": t["function"]["name"],
"description": t["function"]["description"],
"input_schema": t["function"]["parameters"],
} for t in tools]
def anthropic_response_to_openai(resp):
tool_calls = []
for i, block in enumerate(resp["content"]):
if block["type"] == "tool_use":
tool_calls.append({
"id": block["id"],
"type": "function",
"function": {
"name": block["name"],
"arguments": json.dumps(block["input"]),
},
})
return {
"role": "assistant",
"content": None,
"tool_calls": tool_calls,
}
def openai_tool_result_to_anthropic(tool_call_id, output):
return {
"role": "user",
"content": [{"type": "tool_result",
"tool_use_id": tool_call_id,
"content": output}],
}
Schema Evolution and Versioning
The tools protocol evolves: a tool's parameters shift from {"url": string} to {"url": string, "method": string}. The client SDK upgrades, but the model may still describe the old schema. The gateway needs schema version negotiation: each tool carries a schema_version, and when the gateway sees the client-declared version in the request, it auto-selects the matching schema to inject into the tools field. It also maintains a version compatibility table so old-version tool calls still execute under the new schema by filling new fields with defaults.
Best Practices
- Schema validation: validate
toolsdefinitions at the gateway ingress with JSON Schema so bad schemas never waste an upstream call. - Parallel tool calls: both OpenAI and Anthropic support parallel calls, but Gemini allows only one at a time — the gateway must cap to the strictest semantics.
- Error pass-through: when a tool execution fails, return
{"error": "..."}to the model rather than raising; the model then gets a chance to retry or pick another tool. - Fallback prompt template: for models without tools support, serialize the tool list into the system message and parse the model's reply as JSON.
- Tool blocklist: maintain a per-
client_iddisabled-tool list to block dangerous tools (e.g. file deletion).
Unifying the tools protocol lets an agent framework be written once and run across every model.
🚀 Get Started: One-Click Free API Access
Want to call all the free models above with a single API key, no need to sign up for each provider? Apishare.cc provides a unified API Key — one key, 100+ models, free models at zero cost.
👉 Register on Apishare.cc → Get your unified API Key
📊 Want to see more free model rankings? Check out the Sep 2026 Free LLM API Rankings →
Get Started: APIShare Free API Directory
- 🆓 Claim your free credits: Register on APIShare · Sign in to console
- 🔍 Browse every free API and live ranking: APIShare Free API Directory
- 📊 See the leaderboard: Free LLM API Rankings
About the Free API Aggregator
The models covered in this guide are all served through the APIShare free API aggregator, which gives you one key for the whole catalog.
- Full model catalog: APIShare free API directory
- Sign up for a free trial key: Register and claim your API key