Implementation:Openai Openai python Function Tool Param
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Responses_API |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete parameter type for defining a custom function tool that the model can choose to call, provided by the openai-python SDK.
Description
FunctionToolParam is a TypedDict used to define a function in your own code that the model can choose to call via the Responses API. It includes the function name, a JSON Schema describing the parameters, an optional description for the model to decide when to invoke it, and a strict flag for parameter validation. The type field is always "function". This type is auto-generated from the OpenAI OpenAPI specification by Stainless.
Usage
Import FunctionToolParam when constructing tool definitions for a Responses API request where you want to expose custom functions the model can call.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/responses/function_tool_param.py
Signature
class FunctionToolParam(TypedDict, total=False):
"""Defines a function in your own code the model can choose to call."""
name: Required[str]
parameters: Required[Optional[Dict[str, object]]]
strict: Required[Optional[bool]]
type: Required[Literal["function"]]
description: Optional[str]
Import
from openai.types.responses import FunctionToolParam
I/O Contract
Fields
| Name | Type | Required | Description |
|---|---|---|---|
| name | str |
Yes | The name of the function to call. |
| parameters | Optional[Dict[str, object]] |
Yes | A JSON schema object describing the parameters of the function. |
| strict | Optional[bool] |
Yes | Whether to enforce strict parameter validation. Default true.
|
| type | Literal["function"] |
Yes | The type of the function tool. Always "function".
|
| description | Optional[str] |
No | A description of the function, used by the model to determine whether to call it. |
Usage Examples
from openai.types.responses import FunctionToolParam
tool: FunctionToolParam = {
"name": "get_weather",
"type": "function",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"},
},
"required": ["location"],
},
"strict": True,
"description": "Get the current weather for a location.",
}
response = client.responses.create(
model="gpt-4o",
input="What is the weather in London?",
tools=[tool],
)