openai · OpenAI Platform Docs
Function calling | OpenAI API
Teaches how to enable models to generate structured JSON arguments for external functions, including the workflow of defining function schemas, handling model outputs, and executing the resulting tool calls.
Derived skill
Files assembled from official documentation
Viewing SKILL.md
Function calling | OpenAI API
Teaches how to enable models to generate structured JSON arguments for external functions, including the workflow of defining function schemas, handling model outputs, and executing the resulting tool calls.
When To Use
Use when you need to connect a language model to external APIs, databases, or custom code by allowing the model to request specific function executions with structured parameters.
Reference Files
| File | Contains | Use For |
|---|---|---|
SKILL.md | Entry point: scope, routing table, and workflow. | Start here. |
docs/function-calling-openai-api-workflow-guide.md | A guide explaining how to define tools, namespaces, and best practices for implementing function calling with the OpenAI API. | Questions about a guide explaining how to define tools, namespaces, and best practices for implementing function calling with the Ope... |
examples/function-calling-openai-api-openai-api-function-calling.text | A text-based example demonstrating a conversation flow where the model uses a function call to retrieve weather information. | Exact payloads, commands, or snippets shown in A text-based example demonstrating a conversation flow where the model uses a function call to retrieve weather infor... |
examples/function-calling-openai-api-openai-api-python-function-calling-tool-defi.text | A Python code example demonstrating how to define a list of callable tools and function schemas for the OpenAI API. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to define a list of callable tools and function schemas for the OpenAI API. |
examples/function-calling-openai-api-openai-api-function-calling-nodejs.text | A Node.js code example demonstrating how to define tools and use function calling with the OpenAI API. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to define tools and use function calling with the OpenAI API. |
examples/function-calling-openai-api-openai-api-function-calling-python-implement.text | A Python code example demonstrating how to define tools and use the OpenAI client to implement function calling. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to define tools and use the OpenAI client to implement function calling. |
examples/function-calling-openai-api-openai-api-function-calling-nodejs-2.text | A Node.js code example demonstrating how to define tools and use function calling with the OpenAI API. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to define tools and use function calling with the OpenAI API. |
examples/function-calling-openai-api-openai-api-function-calling-json-definition.text | A JSON object defining a weather retrieval function schema for use with OpenAI API function calling. | Exact payloads, commands, or snippets shown in A JSON object defining a weather retrieval function schema for use with OpenAI API function calling. |
examples/function-calling-openai-api-openai-api-function-calling-json-definition-2.text | A JSON object defining a namespace and function tool schema for a CRM customer lookup operation. | Exact payloads, commands, or snippets shown in A JSON object defining a namespace and function tool schema for a CRM customer lookup operation. |
examples/function-calling-openai-api-openai-api-python-pydantic-function-calling.text | A Python code example demonstrating how to use Pydantic models with the OpenAI API to implement function calling. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use Pydantic models with the OpenAI API to implement function calling. |
examples/function-calling-openai-api-openai-api-function-calling-zod-nodejs.text | A Node.js code example demonstrating how to define tool parameters using Zod and implement function calling with the OpenAI SDK. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to define tool parameters using Zod and implement function calling with the... |
examples/function-calling-openai-api-openai-api-function-calling-tool-calls-respo.text | A list of JSON objects representing tool call responses containing function names and arguments for the OpenAI API. | Exact payloads, commands, or snippets shown in A list of JSON objects representing tool call responses containing function names and arguments for the OpenAI API. |
examples/function-calling-openai-api-openai-api-function-calling-python-tool-call.text | A Python code snippet demonstrating how to iterate through tool calls in an OpenAI API completion response and process function arguments. | Exact payloads, commands, or snippets shown in A Python code snippet demonstrating how to iterate through tool calls in an OpenAI API completion response and proces... |
examples/function-calling-openai-api-openai-api-function-calling-nodejs-tool-call.text | A JavaScript code snippet demonstrating how to iterate through tool calls in an OpenAI API completion response and process function arguments. | Exact payloads, commands, or snippets shown in A JavaScript code snippet demonstrating how to iterate through tool calls in an OpenAI API completion response and pr... |
examples/function-calling-openai-api-openai-api-function-calling-response-example.text | A list of JSON objects representing example tool call responses from the OpenAI API including function names and arguments. | Exact payloads, commands, or snippets shown in A list of JSON objects representing example tool call responses from the OpenAI API including function names and argu... |
examples/function-calling-openai-api-openai-api-function-calling-python-tool-call-2.text | A Python code snippet demonstrating how to iterate through tool calls in an API response and process function outputs. | Exact payloads, commands, or snippets shown in A Python code snippet demonstrating how to iterate through tool calls in an API response and process function outputs. |
examples/function-calling-openai-api-openai-api-function-calling-response-loop-ja.text | A JavaScript code snippet demonstrating how to iterate through tool calls in an OpenAI API response and process function arguments. | Exact payloads, commands, or snippets shown in A JavaScript code snippet demonstrating how to iterate through tool calls in an OpenAI API response and process funct... |
examples/function-calling-openai-api-openai-api-function-calling-python-implement-2.text | A Python code snippet demonstrating the logic for routing function calls based on model-generated tool names and arguments. | Exact payloads, commands, or snippets shown in A Python code snippet demonstrating the logic for routing function calls based on model-generated tool names and argu... |
examples/function-calling-openai-api-openai-api-function-calling-javascript-imple.text | A JavaScript code example demonstrating how to handle function calls and arguments within an OpenAI API integration. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to handle function calls and arguments within an OpenAI API integration. |
examples/function-calling-openai-api-openai-api-function-calling-python-chat-comp.text | A Python code example demonstrating how to use the chat completions endpoint with the tools parameter for function calling. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the chat completions endpoint with the tools parameter for function ca... |
examples/function-calling-openai-api-openai-api-function-calling-chat-completions.text | A JavaScript code example demonstrating how to implement function calling using the OpenAI Chat Completions API. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to implement function calling using the OpenAI Chat Completions API. |
examples/function-calling-openai-api-openai-api-function-calling-python-client-re.text | A Python code snippet demonstrating how to use the OpenAI client to create a response with tool definitions for function calling. | Exact payloads, commands, or snippets shown in A Python code snippet demonstrating how to use the OpenAI client to create a response with tool definitions for funct... |
examples/function-calling-openai-api-openai-api-function-calling-javascript.text | A JavaScript code example demonstrating how to implement function calling using the OpenAI API. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to implement function calling using the OpenAI API. |
examples/function-calling-openai-api-openai-api-function-calling-conversation.text | A text-based representation of a multi-turn conversation demonstrating how the model uses function calling to retrieve weather information and send emails. | Exact payloads, commands, or snippets shown in A text-based representation of a multi-turn conversation demonstrating how the model uses function calling to retriev... |
examples/function-calling-openai-api-openai-api-function-calling-tool-choice-json.text | A JSON object demonstrating the tool_choice parameter configuration with specific allowed functions for the OpenAI API. | Exact payloads, commands, or snippets shown in A JSON object demonstrating the toolchoice parameter configuration with specific allowed functions for the OpenAI API. |
examples/function-calling-openai-api-openai-api-function-calling-json-definition-3.text | A JSON object defining a weather retrieval function schema with strict mode enabled for OpenAI API function calling. | Exact payloads, commands, or snippets shown in A JSON object defining a weather retrieval function schema with strict mode enabled for OpenAI API function calling. |
examples/function-calling-openai-api-openai-api-function-calling-json-definition-4.text | A JSON object defining a weather retrieval function schema for use with OpenAI API function calling. | Exact payloads, commands, or snippets shown in A JSON object defining a weather retrieval function schema for use with OpenAI API function calling. |
examples/function-calling-openai-api-openai-api-function-calling-json-definition-5.text | A JSON object defining a weather retrieval function schema with strict mode enabled for OpenAI API function calling. | Exact payloads, commands, or snippets shown in A JSON object defining a weather retrieval function schema with strict mode enabled for OpenAI API function calling. |
examples/function-calling-openai-api-openai-api-function-calling-json-definition-6.text | A JSON object defining a weather retrieval function schema for use with OpenAI API function calling. | Exact payloads, commands, or snippets shown in A JSON object defining a weather retrieval function schema for use with OpenAI API function calling. |
examples/function-calling-openai-api-openai-api-function-calling-python.text | A Python code example demonstrating how to define tools and use function calling with the OpenAI client. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to define tools and use function calling with the OpenAI client. |
examples/function-calling-openai-api-openai-api-function-calling-nodejs-3.text | A Node.js code example demonstrating how to define tools and use function calling with the OpenAI API. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to define tools and use function calling with the OpenAI API. |
examples/function-calling-openai-api-openai-api-function-calling-tool-definition-.text | A JSON array representing the tool definition and function call structure used in the OpenAI API function calling process. | Exact payloads, commands, or snippets shown in A JSON array representing the tool definition and function call structure used in the OpenAI API function calling pro... |
examples/function-calling-openai-api-openai-api-function-calling-stream-arguments.text | A Python code snippet demonstrating how to iterate through a stream of chat completion chunks to aggregate tool call arguments into a final dictionary. | Exact payloads, commands, or snippets shown in A Python code snippet demonstrating how to iterate through a stream of chat completion chunks to aggregate tool call... |
examples/function-calling-openai-api-openai-api-function-calling-stream-arguments-2.text | A JavaScript code snippet demonstrating how to iterate through a stream of tool call chunks and aggregate function arguments into a final object. | Exact payloads, commands, or snippets shown in A JavaScript code snippet demonstrating how to iterate through a stream of tool call chunks and aggregate function ar... |
examples/function-calling-openai-api-openai-api-function-calling-tool-definition.text | A JSON object demonstrating a model tool definition and the resulting function call arguments for a weather retrieval operation. | Exact payloads, commands, or snippets shown in A JSON object demonstrating a model tool definition and the resulting function call arguments for a weather retrieval... |
examples/function-calling-openai-api-openai-api-function-calling-python-2.text | A Python code example demonstrating how to define tools and use function calling with the OpenAI client. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to define tools and use function calling with the OpenAI client. |
examples/function-calling-openai-api-openai-api-function-calling-nodejs-tool-defi.text | A JavaScript code snippet demonstrating how to define a weather function tool within the OpenAI API client. | Exact payloads, commands, or snippets shown in A JavaScript code snippet demonstrating how to define a weather function tool within the OpenAI API client. |
examples/function-calling-openai-api-openai-api-function-calling-response-stream-.text | A text representation of a streamed JSON response containing function call events and argument deltas from the OpenAI API. | Exact payloads, commands, or snippets shown in A text representation of a streamed JSON response containing function call events and argument deltas from the OpenAI... |
examples/function-calling-openai-api-openai-api-function-calling-stream-event-han.text | A JavaScript code snippet demonstrating how to aggregate tool call arguments from a streaming response event loop. | Exact payloads, commands, or snippets shown in A JavaScript code snippet demonstrating how to aggregate tool call arguments from a streaming response event loop. |
examples/function-calling-openai-api-openai-api-function-calling-realtime-stream-.text | A JavaScript code snippet demonstrating how to iterate through a stream of events to accumulate function call arguments and tool calls. | Exact payloads, commands, or snippets shown in A JavaScript code snippet demonstrating how to iterate through a stream of events to accumulate function call argumen... |
examples/function-calling-openai-api-openai-api-function-calling-response.text | A text representation of an OpenAI API function call response containing the function name and arguments. | Exact payloads, commands, or snippets shown in A text representation of an OpenAI API function call response containing the function name and arguments. |
examples/function-calling-openai-api-openai-api-python-function-calling-tool-defi-2.text | A Python code example demonstrating how to define a custom tool within the OpenAI API client to enable function calling capabilities. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to define a custom tool within the OpenAI API client to enable function calli... |
examples/function-calling-openai-api-openai-api-function-calling-nodejs-4.text | A Node.js code example demonstrating how to define a custom tool and use the OpenAI client to request a function call. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to define a custom tool and use the OpenAI client to request a function call. |
examples/function-calling-openai-api-openai-api-function-calling-2.text | A text representation of a function calling interaction involving a custom tool call and code execution input. | Exact payloads, commands, or snippets shown in A text representation of a function calling interaction involving a custom tool call and code execution input. |
examples/function-calling-openai-api-openai-api-function-calling-python-grammar.text | A Python code example demonstrating how to use the OpenAI API to implement function calling with a custom grammar definition. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI API to implement function calling with a custom grammar def... |
examples/function-calling-openai-api-openai-api-function-calling-javascript-gramm.text | A JavaScript code example demonstrating how to use function calling with a custom grammar definition using the OpenAI client. | Exact payloads, commands, or snippets shown in A JavaScript code example demonstrating how to use function calling with a custom grammar definition using the OpenAI... |
examples/function-calling-openai-api-openai-api-function-calling-tool-call.text | A text representation of a custom tool call object containing a reasoning type and a math expression input. | Exact payloads, commands, or snippets shown in A text representation of a custom tool call object containing a reasoning type and a math expression input. |
examples/function-calling-openai-api-openai-api-function-calling-regex-pattern.text | A text-based example demonstrating a regex pattern used to identify specific sentence structures for function calling tasks. | Exact payloads, commands, or snippets shown in A text-based example demonstrating a regex pattern used to identify specific sentence structures for function calling... |
examples/function-calling-openai-api-openai-api-function-calling-regex-extraction.text | A text-based example demonstrating how to use function calling to extract structured data like subject, verb, and object from sentences using regular expressions. | Exact payloads, commands, or snippets shown in A text-based example demonstrating how to use function calling to extract structured data like subject, verb, and obj... |
examples/function-calling-openai-api-openai-api-function-calling-expression-gramm.text | A text-based example defining a grammar for mathematical expressions including numbers, operators, and terms for use with function calling. | Exact payloads, commands, or snippets shown in A text-based example defining a grammar for mathematical expressions including numbers, operators, and terms for use... |
examples/function-calling-openai-api-openai-api-python-function-calling-grammar.text | A Python code example demonstrating how to use the OpenAI client to implement function calling with a specific regex grammar. | Exact payloads, commands, or snippets shown in A Python code example demonstrating how to use the OpenAI client to implement function calling with a specific regex... |
examples/function-calling-openai-api-openai-api-function-calling-nodejs-5.text | A Node.js code example demonstrating how to implement function calling using the OpenAI client. | Exact payloads, commands, or snippets shown in A Node.js code example demonstrating how to implement function calling using the OpenAI client. |
examples/function-calling-openai-api-openai-api-function-calling-tool-call-2.text | A text representation of an OpenAI API tool call object containing a timestamp function call. | Exact payloads, commands, or snippets shown in A text representation of an OpenAI API tool call object containing a timestamp function call. |
What This Skill Covers
-
- Define a list of callable tools for the model tools = [ "type": "function", "name": "gethoroscope", "description": "Get today's horoscope for an astrologi...
- Main sections:
Defining functions,Defining namespaces,Tool search,Best practices for defining functions,Token Usage.
Workflow
- Open the most relevant file under
docs/for the exact documented workflow and wording. - Open
schemas/files for exact structured contracts. - Open
examples/files for concrete requests, commands, snippets, and manifests. - Do not add behavior or configuration that is not present in the attached source files.
Canonical source: https://developers.openai.com/api/docs/guides/function-calling
