Prompt Buddy logoPrompt Buddy

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.

Import to Prompt Buddy

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

FileContainsUse For
SKILL.mdEntry point: scope, routing table, and workflow.Start here.
docs/function-calling-openai-api-workflow-guide.mdA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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-.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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-.textA 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.textA 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-.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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.textA 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

    1. 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

  1. Open the most relevant file under docs/ for the exact documented workflow and wording.
  2. Open schemas/ files for exact structured contracts.
  3. Open examples/ files for concrete requests, commands, snippets, and manifests.
  4. 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