Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Custom Tool Param

From Leeroopedia
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

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?",
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment