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 Model

From Leeroopedia
Revision as of 13:37, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Openai_Openai_python_Custom_Tool_Model.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains API_Types, Python
Last Updated 2026-02-15 00:00 GMT

Overview

Concrete type for representing a custom tool response model provided by the openai-python SDK.

Description

CustomTool is a Pydantic model class that represents a custom tool that processes input using a specified format. It extends BaseModel and includes a name field identifying the tool in tool calls, a type field fixed to "custom", an optional description providing additional context about the tool, and an optional format field of type CustomToolInputFormat that specifies the input format (defaulting to unconstrained text when not provided).

Usage

Import this type when you need to deserialize or inspect custom tool definitions returned in API responses. This is the response model counterpart to CustomToolParam which is used for request construction.

Code Reference

Source Location

Signature

class CustomTool(BaseModel):
    """A custom tool that processes input using a specified format."""
    name: str
    type: Literal["custom"]
    description: Optional[str] = None
    format: Optional[CustomToolInputFormat] = None

Import

from openai.types.responses import CustomTool

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 Optional[str] No Optional description of the custom tool, used to provide more context.
format Optional[CustomToolInputFormat] No The input format for the custom tool. Default is unconstrained text.

Usage Examples

from openai.types.responses import CustomTool

# Inspect a custom tool from a response
response = client.responses.create(
    model="gpt-4o",
    tools=[{"type": "custom", "name": "my_tool"}],
    input="Use my_tool to process data",
)

for tool in response.tools:
    if isinstance(tool, CustomTool):
        print(f"Tool: {tool.name}, Type: {tool.type}")
        if tool.description:
            print(f"Description: {tool.description}")

Related Pages

Page Connections

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