Implementation:Openai Openai python Custom Tool Param
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Python |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete type for parameterizing a custom tool in a request provided by the openai-python SDK.
Description
CustomToolParam is a TypedDict that defines the parameter structure for specifying a custom tool in a Responses API request. It requires a name field (string identifying the tool in tool calls) and a type field fixed to "custom". Optional fields include description (providing more context about the tool) and format of type CustomToolInputFormat (specifying the input format, defaulting to unconstrained text).
Usage
Import this type when constructing a tool list for a response request that includes custom tools. This is the request parameter counterpart to the CustomTool response model.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/responses/custom_tool_param.py
Signature
class CustomToolParam(TypedDict, total=False):
"""A custom tool that processes input using a specified format."""
name: Required[str]
type: Required[Literal["custom"]]
description: str
format: CustomToolInputFormat
Import
from openai.types.responses import CustomToolParam
I/O Contract
Fields
| Name | Type | Required | Description |
|---|---|---|---|
| name | str | Yes | The name of the custom tool, used to identify it in tool calls. |
| type | Literal["custom"] | Yes | The type of the custom tool. Always "custom". |
| description | str | No | Optional description of the custom tool, used to provide more context. |
| format | CustomToolInputFormat | No | The input format for the custom tool. Default is unconstrained text. |
Usage Examples
from openai.types.responses import CustomToolParam
tool: CustomToolParam = {
"type": "custom",
"name": "weather_lookup",
"description": "Looks up current weather for a city",
}
response = client.responses.create(
model="gpt-4o",
tools=[tool],
input="What is the weather in San Francisco?",
)