Learning resourcesReviewed · OpenAI

OpenAI Function Calling Guide

OpenAI's function calling guide teaches developers how to connect models to application data and actions, but developers must implement and execute the tools themselves. It covers JSON Schema functions, custom tools with text inputs, strict mode, streaming and tool selection.

Researched 12 Nov 2026

In short.

OpenAI's function calling guide is a practical reference for developers adding tools to AI applications, but application code must handle execution and service integration. It explains tool definitions, call identifiers, conversation history, strict schemas, streaming and grammar-constrained custom tools. Its examples include hardcoded results and require adaptation. API prices, minimum SDK versions and reuse rights are unspecified, and runtime behavior was not assessed.

Researched and written by an AI model and checked by a second AI model. How it works

Coverage is the complete selected page at [https://developers.openai.com/api/docs/guides/function-calling.md], including embedded examples, warnings and notices present in the supplied text. Linked documentation, repositories, external grammar references and other folders are excluded. No explicit licence grant is present in the supplied page, so redistribution rights remain unknown. Code examples and illustrated outputs were not executed or independently verified.

The overview

Identity

Function calling is an OpenAI developer documentation guide at [https://developers.openai.com/api/docs/guides/function-calling.md]. It teaches how to expose application functionality to a model and return results through the OpenAI API.

All code examples in the captured page use the Responses API. The page says it also shows Chat Completions integrations using GPT-5.6 Terra, but no Chat Completions code appears in the captured page; its only Chat Completions detail is that those requests are non-strict by default. It directs Agents API sessions to separate documentation. Examples span JavaScript, Python, Go, Java and Ruby, with additional C# dispatch code.

Assessment

The guide is useful for understanding both the basic tool-calling loop and the controls needed to implement it. Its practical strength is showing the application receiving a model request, running a function and returning a result associated with that request.

It is a strong starting reference for an OpenAI integration. Production behavior still depends on the application's services, dispatch logic and handling of repeated calls. The supplied evidence establishes no measured accuracy, latency or reliability.

Users

Beginners with basic programming and JSON knowledge get definitions of tools, tool calls and tool outputs, followed by concrete examples. Experienced developers get details on strict schemas, namespaces, deferred loading, parallel calls and streaming argument assembly.

Relevant applications include weather lookups, account queries and order actions. Readers need to be able to write application code and connect the demonstrated functions to their own data or services.

Capabilities

The guide explains JSON Schema function definitions, namespaces for grouping related tools and tool search for loading deferred tools. It documents automatic selection, required calls, forcing a named function, restricting allowed tools and disabling parallel calls.

It also covers streaming function arguments and custom tools that receive arbitrary text. Custom inputs can be constrained with Lark grammars or regex patterns, subject to the supported syntax and complexity limits described on the page.

Using it

Requirements

An implementation needs access to the OpenAI API, a compatible model, application code that handles tool calls and an implementation of each exposed function. The examples assume a configured OpenAI client; credential setup and minimum SDK versions are unspecified.

The captured guide states that GPT-6 Astra and GPT-6.1 Sol require Responses for tool calling, and that tool search requires gpt-5.4 or later. These are documented compatibility statements; model availability and SDK compatibility were not independently assessed.

Strict function schemas require additionalProperties set to false for every object and every property listed as required. The page describes nullable types for representing optional values and warns that only a subset of JSON Schema is supported.

Mechanism

The application sends a prompt and tool definitions. The model may return a tool call containing a name, arguments and call_id. Application code dispatches the function, then returns its result with the matching call_id. A subsequent model response can contain an answer or further tool calls.

Responses can contain zero, one or multiple calls. The guide shows preserving model output in conversation history or continuing through previous_response_id, and says returned reasoning items must accompany tool results when applicable. Function results are typically strings containing text, JSON or status information; image and file objects are also described.

Setup

Define a function with a clear name, description and parameter schema, then include it in the request's tools array. Implement the matching application function and dispatcher, parse returned arguments, preserve response history and append each result before making the next model request.

For predictable argument structure, the guide recommends explicitly enabling strict mode. It also recommends starting with a small set of functions, using fewer than 20 as a soft guideline, and evaluating tool selection as the available set grows. For streaming, accumulate argument fragments separately for each output item.

Example

The horoscope example defines get_horoscope with one required string argument, sign, and strict mode enabled. Its intended flow has the model request the function for Aquarius, application code generate a result and a follow-up Responses request produce the final answer.

The horoscope result is hardcoded. Several weather and email snippets also use illustrative values or local fixtures; the Java and C# email fixtures print inputs while reporting a sent status. Real integrations need service implementations and results that reflect what actually happened. No example was executed.

Assessment & evidence

Limitations

Strict mode constrains argument structure; schema compliance alone does not establish that the selected action or its result is correct. The guide documents unsupported schema features, grammar complexity errors and grammar-conforming text that can still be semantically wrong.

The page also warns that multiple function calls can disable strict mode for fine-tuned models. It describes additional schema processing latency and schema-caching retention limits specifically for fine-tuned models.

Some examples need careful reconciliation. The strict-mode units example includes null in its type but excludes null from its enum, leaving its intended nullable behavior inconsistent. Weather snippets use both location and coordinate arguments, so definitions and dispatch code must match when adapted.

Readers targeting Chat Completions should note that the captured page contains no code example for that API; its API-calling examples use Responses.

Reasoning

The guide's value comes from connecting vocabulary, request structure and application responsibilities in one resource. This makes it easier to understand where a model's request ends and application execution begins.

Based on the documented interfaces, JSON Schema functions appear the simpler starting point for named operations with typed arguments. Custom tools suit services that need text in an existing syntax, while grammar constraints introduce additional implementation work. This is an architectural inference, not a performance comparison.

Alternatives

The page distinguishes application-defined functions from OpenAI built-in tools for capabilities such as web search, code execution and MCP access. It also points to the Agents SDK for recurring orchestration and separate function documentation for Agents API sessions.

These linked resources are outside the supplied evidence. Their setup, costs, limitations and comparative suitability are not assessed, and the page provides no measured comparison with other providers or frameworks.

Evidence

The evidence is the captured OpenAI documentation page, including its explanations, embedded code, sample outputs and warnings. Sample outputs illustrate intended behavior; they establish no independently observed execution results. No code was run, and runtime compatibility, accuracy, latency and production readiness are not assessed.

The captured source revision is sha256:d2e91e8bb84c5d20de59774693de38c7f1fcc20823b5aee375e7ad8d2a9d7c4e. The retained source file is selected-page.txt at the original documentation address.

Access & freshness

Costs

The page states that function definitions consume model context and are billed as input tokens. The demonstrated flow includes an initial model request and a follow-up request carrying tool results; longer interactions can require additional requests.

The guide suggests limiting initially loaded definitions, using deferred loading and preserving stable tool lists for prompt caching. It provides no token prices, example spending totals or quantified savings. External service charges, hosting costs and total operating cost are unknown.

Rights

The supplied page contains no explicit licence grant or reuse terms for its documentation or embedded examples. Permission to redistribute the captured page or snippets, including any attribution requirements, is unknown from this evidence. Licences and terms on linked pages are outside the supplied scope.

Freshness

The source was captured on 2026-11-12 at 11:47:19.642 UTC. This identifies the captured version's acquisition time; the supplied page gives no publication date or last-update date.

Model support, API defaults and SDK behavior are version-sensitive. The report reflects the captured page's statements, and subsequent changes are unknown.

Actions

For a first implementation, adapt the horoscope flow to one small lookup function, explicitly enable strict mode and keep the schema consistent with the dispatcher. Handle zero or multiple calls, preserve required history and return results against the correct call_id.

Before connecting real services, verify the chosen model/API pairing and SDK compatibility, replace hardcoded fixtures and resolve the nullable enum inconsistency. Evaluate task accuracy, failure handling, latency and actual spending in the intended application; the guide supplies no measured baseline.

Evidence for this report

selected-page.txtselected · checked 2026-11-12