Claude API Function Calling vs OpenAI Tools
The short answer
Both Claude and OpenAI let a model decide to call a function you define, receive structured arguments back, and continue the conversation once you return a result. The core idea — describe tools with JSON Schema, let the model choose when to call them, feed results back as a new turn — is nearly identical. The differences are in message shape, how parallel calls are represented, how forced tool choice works, and how streaming exposes partial arguments. If you're choosing between the two for a new project, the decision usually comes down to which model's reasoning you prefer, not the mechanics of the tool-calling API itself.
This matters because "function calling" and "tool use" are the foundation of most production agents — database lookups, calculators, search, internal APIs. Getting the request/response format right the first time saves you from debugging malformed JSON in production. Below is a side-by-side look at both APIs so you know exactly what changes if you switch, or if you're building something that needs to support both.
How Claude's tool use works
Claude calls this tool use. You define tools in the tools array of a messages request, each with a name, description, and input_schema (JSON Schema):
{
"model": "claude-opus-4",
"max_tokens": 1024,
"tools": [
{
"name": "get_weather",
"description": "Get current weather for a city",
"input_schema": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
],
"messages": [{ "role": "user", "content": "Weather in Lisbon?" }]
}
When Claude decides to call a tool, the response contains a tool_use content block with an id, name, and input object. You run the function yourself, then send the result back as a tool_result content block inside a user message, referencing the same tool_use_id. Claude continues the conversation from there — often producing another tool call or a final text answer.
Claude also supports forcing tool use via tool_choice, parallel tool calls in a single response (multiple tool_use blocks), and streaming partial input JSON as it's generated.
How OpenAI's tools work
OpenAI's current approach is also called tools (the older functions parameter is deprecated but still works similarly). You define functions with a type: "function" wrapper:
{
"model": "gpt-4.1",
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
}
],
"messages": [{ "role": "user", "content": "Weather in Lisbon?" }]
}
The model returns tool_calls on the assistant message — an array of objects with id, function.name, and function.arguments (a JSON string, not a parsed object). You run the function, then append a message with role: "tool", the matching tool_call_id, and the stringified result.
Key differences that actually affect your code
Argument encoding. OpenAI returns arguments as a raw JSON string you must parse yourself. Claude returns input as an already-parsed JSON object. This is a small but real difference if you're writing strict typed handlers.
Result message shape. OpenAI expects a dedicated role: "tool" message. Claude expects a tool_result block nested inside a role: "user" message's content array. If you're building a dual-backend abstraction layer, this is the part that needs the most adapter logic.
Forcing a specific tool. Both support forcing tool use, but the parameter shapes differ — OpenAI uses tool_choice: {"type": "function", "function": {"name": "..."}}, Claude uses tool_choice: {"type": "tool", "name": "..."}. Functionally equivalent, syntactically different.
Parallel tool calls. Both can return multiple tool calls in one turn. OpenAI exposes them as multiple entries in tool_calls; Claude exposes them as multiple tool_use blocks in content. You need to handle both in a loop regardless of provider.
Streaming. Both stream partial arguments as they're generated (useful for showing "thinking" UI), but the delta event names and accumulation logic differ. Claude's streaming is documented in detail at /docs/streaming, and the general message/tool flow is covered in /docs/messages and /docs/tools.
Chained reasoning. Claude tends to narrate its reasoning before calling a tool when prompted to; OpenAI's tool calls are typically terser. Neither is objectively "better" — it affects how much you need to post-process the text portion of the response.
Picking one (or supporting both)
If you're already standardized on Claude for its context window, writing quality, or safety behavior, its tool use API is mature enough for production agents: multi-step tool chains, parallel calls, and forced tool choice all work reliably. If you need to support both providers — say, for fallback or A/B testing models — budget time for a small adapter layer that normalizes argument parsing and result message shape, since those are the two places behavior diverges.
If you want Claude's tool use without wiring raw SSE parsing and message-block bookkeping into every service, SubToAPI exposes it as a standard HTTPS API with sub_live_... application keys, so your backend calls /v1/messages with tools and streaming the same way it would call any REST API, with usage metadata and team seats included. Check /docs/quickstart to see the request shape, or /pricing if you're comparing cost against running your own Anthropic account directly. A free trial is available at /signup.
FAQ
Is Claude's tool use the same as OpenAI's function calling?
Conceptually yes — both let the model request a function call with structured JSON arguments, then continue once you return a result. The request/response field names and message structure differ enough that code isn't portable without an adapter.
Can I force Claude or GPT to always use a specific tool?
Yes, both support forced tool choice. Claude uses tool_choice: {"type": "tool", "name": "..."}; OpenAI uses tool_choice: {"type": "function", "function": {"name": "..."}}. Behavior is equivalent, syntax differs.
Does Claude support parallel tool calls like OpenAI?
Yes. Claude can return multiple tool_use blocks in a single response, equivalent to OpenAI's array of tool_calls. Both require your code to loop over multiple calls rather than assume exactly one per turn.