AgenticFrameworksModels

Function calling

by OpenAI

IntermediateDocumentationFree~30-40 minute read; reference docs, self-paced

The spec every other tool-calling API imitates, including the parts that bite.

Start LearningAdded Jul 4, 2026 · Updated Aug 11, 2026

Overview

OpenAI's function calling guide is the reference for giving a model access to code and external systems, and it is the contract most other agent tooling is written against. It opens with a 'How it works' walkthrough of the loop — you send tool definitions with the request, the model returns a function call with arguments, your code executes it, and you append the result and call again — then works through defining functions as JSON Schema, grouping related tools with namespaces, tool search for large tool sets, and a best-practices section on naming and describing functions so the model chooses correctly. Strict mode gets particular attention: it is built on the same Structured Outputs machinery, requires additionalProperties set to false with every field marked required, and the guide recommends leaving it enabled. Later sections cover the token cost that tool definitions add to every request, handling function calls across a multi-turn conversation, additional configuration including disabling parallel tool calls and restricting the callable set with allowed_tools without editing the tools array, streaming function-call argument deltas so a UI can show progress, custom tools that accept arbitrary text instead of JSON, and constraining that text with Lark or Regex context-free grammars. Code examples appear in JavaScript/TypeScript, Python, Go and curl, targeting GPT-5-family models including gpt-5.6, gpt-5.4 and o4-mini.

At a Glance

Topic
Agentic
Level
Intermediate
Format
Documentation
Cost
Free
Duration
~30-40 minute read; reference docs, self-paced
Provider
OpenAI
Hands-on
Yes — code/exercises
Certificate
None

What You’ll Learn

  • Define callable tools as JSON Schema the model can select from
  • Run the full call loop and feed tool results back to the model
  • Enable strict mode so generated arguments always match your schema
  • Group related tools with namespaces and scale past small tool sets
  • Restrict which tools are callable per request using allowed_tools
  • Stream function-call argument deltas to show progress in a UI
  • Constrain free-text custom tools with Lark or Regex grammars
  • Estimate the token cost your tool definitions add to every request

Highlights

  • The canonical spec for the tool-calling format most third-party SDKs and agent frameworks imitate
  • Strict mode is documented with its real constraints — additionalProperties false, all fields required — not merely advertised
  • Covers context-free grammars for custom tools, a capability almost no third-party tutorial explains
  • Side-by-side samples in JavaScript/TypeScript, Python, Go and curl rather than one blessed language
  • Read it with a grain of salt: independent benchmarking by BoundaryML found strict function calling can select fewer tools than expected and occasionally fall back to plain text, so treat it as reliable formatting rather than reliable reasoning

Who It’s For

Best For

  • Engineers building tool-using agents on the OpenAI API
  • Developers porting agent code between model providers
  • Teams debugging why a model keeps picking the wrong tool

Prerequisites

  • Comfort with JSON Schema and REST APIs
  • Working knowledge of Python, JavaScript/TypeScript or Go
  • An OpenAI API key and a running request loop to modify

FAQ

What is Function calling?

OpenAI's reference for letting a model call your code. It covers the full request loop, JSON Schema tool definitions, strict mode, namespaces and tool search for large tool sets, streaming argument deltas, and grammar-constrained custom tools. Read it before adopting any agent framework, because most of them are wrappers over exactly this contract and inherit its constraints.

Is Function calling free?

Function calling is free to access.

What level is Function calling for?

Function calling is aimed at a intermediate audience. Recommended background: Comfort with JSON Schema and REST APIs, Working knowledge of Python, JavaScript/TypeScript or Go, An OpenAI API key and a running request loop to modify.

How long does Function calling take?

Expect roughly ~30-40 minute read; reference docs, self-paced. Most learners work through it at their own pace.

What will I learn from Function calling?

You'll learn: Define callable tools as JSON Schema the model can select from; Run the full call loop and feed tool results back to the model; Enable strict mode so generated arguments always match your schema; Group related tools with namespaces and scale past small tool sets; Restrict which tools are callable per request using allowed_tools; Stream function-call argument deltas to show progress in a UI; Constrain free-text custom tools with Lark or Regex grammars; Estimate the token cost your tool definitions add to every request.

Topics

function callingtool useOpenAI APIJSON Schemaagents

Sources

This page was written from 2 sources, 1 on domains other than developers.openai.com.

  1. 1.developers.openai.comfunction callingvendor
  2. 2.boundaryml.comsota function calling