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 Response Input Param

From Leeroopedia
Revision as of 13:40, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Openai_Openai_python_Response_Input_Param.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 alias for the complete response input parameter collection provided by the openai-python SDK.

Description

The response_input_param.py module defines ResponseInputParam, the top-level type alias that represents the full list of input items for the OpenAI Responses API. This module re-declares all the TypedDict input item types (identical to those in response_input_item_param.py) and defines the final ResponseInputParam as a List[ResponseInputItemParam].

The module contains two key type aliases:

  • ResponseInputItemParam -- A Union of 25 TypedDict types representing every kind of input item (messages, tool call outputs, MCP interactions, shell commands, patch operations, item references, etc.). This is the same union as in response_input_item_param.py.
  • ResponseInputParam -- Defined as List[ResponseInputItemParam], this is the type used for the input parameter in client.responses.create() when passing structured input (as opposed to a plain string).

The TypedDict classes re-declared in this module include: Message, ComputerCallOutput, FunctionCallOutput, ImageGenerationCall, LocalShellCall, LocalShellCallOutput, ShellCall, ShellCallOutput, ApplyPatchCall, ApplyPatchCallOutput, McpListTools, McpApprovalRequest, McpApprovalResponse, McpCall, and ItemReference.

This file is auto-generated from the OpenAI API spec by the Stainless code generation toolchain.

Usage

Use ResponseInputParam when annotating the input parameter for response creation calls. It is the list type that wraps all individual input item TypedDicts, enabling type-safe construction of multi-item conversation inputs. In ResponseCreateParamsBase, the input field is typed as Union[str, ResponseInputParam], meaning you can provide either a plain string or a structured list of input items.

Code Reference

Source Location

Signature

ResponseInputItemParam: TypeAlias = Union[
    EasyInputMessageParam,
    Message,
    ResponseOutputMessageParam,
    ResponseFileSearchToolCallParam,
    ResponseComputerToolCallParam,
    ComputerCallOutput,
    ResponseFunctionWebSearchParam,
    ResponseFunctionToolCallParam,
    FunctionCallOutput,
    ResponseReasoningItemParam,
    ResponseCompactionItemParamParam,
    ImageGenerationCall,
    ResponseCodeInterpreterToolCallParam,
    LocalShellCall,
    LocalShellCallOutput,
    ShellCall,
    ShellCallOutput,
    ApplyPatchCall,
    ApplyPatchCallOutput,
    McpListTools,
    McpApprovalRequest,
    McpApprovalResponse,
    McpCall,
    ResponseCustomToolCallOutputParam,
    ResponseCustomToolCallParam,
    ItemReference,
]

ResponseInputParam: TypeAlias = List[ResponseInputItemParam]

Import

from openai.types.responses.response_input_param import (
    ResponseInputParam,
    ResponseInputItemParam,
)
# Or via the top-level re-export:
from openai.types.responses import ResponseInputParam

I/O Contract

Inputs

Name Type Required Description
(list elements) ResponseInputItemParam Yes Each element is one of 25 TypedDict types representing an input item (message, tool output, MCP call, shell command, patch operation, item reference, etc.)

The individual TypedDict types within the union accept the same fields documented in the Implementation:Openai_Openai_python_Response_Input_Item_Param page.

Outputs

Name Type Description
ResponseInputParam TypeAlias List[ResponseInputItemParam] -- a list of input items for the Responses API input parameter
ResponseInputItemParam TypeAlias Union of 25 TypedDict types representing individual input items

Usage Examples

Simple Text Message Input

from openai import OpenAI
from openai.types.responses import ResponseInputParam

client = OpenAI()

input_items: ResponseInputParam = [
    {
        "role": "user",
        "content": [{"type": "input_text", "text": "Hello, how are you?"}],
        "type": "message",
    }
]

response = client.responses.create(
    model="gpt-4o",
    input=input_items,
)

Multi-Turn Conversation With Function Output

from openai.types.responses import ResponseInputParam

input_items: ResponseInputParam = [
    {
        "role": "user",
        "content": [{"type": "input_text", "text": "What is the weather in NYC?"}],
        "type": "message",
    },
    {
        "call_id": "call_weather_123",
        "output": '{"temperature": 65, "condition": "cloudy"}',
        "type": "function_call_output",
    },
    {
        "role": "user",
        "content": [{"type": "input_text", "text": "Should I bring an umbrella?"}],
        "type": "message",
    },
]

Using System and Developer Messages

from openai.types.responses import ResponseInputParam

input_items: ResponseInputParam = [
    {
        "role": "developer",
        "content": [{"type": "input_text", "text": "You are a helpful assistant."}],
        "type": "message",
    },
    {
        "role": "system",
        "content": [{"type": "input_text", "text": "Respond concisely."}],
        "type": "message",
    },
    {
        "role": "user",
        "content": [{"type": "input_text", "text": "Explain recursion."}],
        "type": "message",
    },
]

Including an Item Reference

from openai.types.responses import ResponseInputParam

input_items: ResponseInputParam = [
    {
        "id": "item_existing_abc",
        "type": "item_reference",
    },
    {
        "role": "user",
        "content": [{"type": "input_text", "text": "Continue from where we left off."}],
        "type": "message",
    },
]

Related Pages

Page Connections

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