Implementation:Openai Openai python Response Create Params
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Python |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete type definitions for Responses API creation parameters provided by the openai-python SDK.
Description
The response_create_params.py module defines the TypedDict parameter types used when creating a new response via the OpenAI Responses API. It contains three primary types organized in an inheritance hierarchy:
ResponseCreateParamsBase-- The base TypedDict that defines all shared parameters for response creation, includingmodel,input,instructions,tools,tool_choice,temperature,top_p,max_output_tokens, and many more.ResponseCreateParamsNonStreaming-- Extends the base withstream: Optional[Literal[False]]for non-streaming requests.ResponseCreateParamsStreaming-- Extends the base withstream: Required[Literal[True]]for streaming requests.
The final ResponseCreateParams is a Union of the streaming and non-streaming variants.
Additional helper types defined in this module include:
ContextManagement-- TypedDict for context management (compaction) configuration.Conversation-- TypeAlias for conversation references (Union[str, ResponseConversationParam]).StreamOptions-- TypedDict for streaming configuration options (e.g., obfuscation).ToolChoice-- TypeAlias union of all tool choice parameter variants.
This file is auto-generated from the OpenAI API spec by the Stainless code generation toolchain.
Usage
Use these types when constructing parameters for client.responses.create() calls, or when annotating function signatures that accept response creation configuration. The streaming vs. non-streaming distinction determines whether the API returns a single response or a stream of server-sent events.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/responses/response_create_params.py
- Lines: 1-348
Signature
class ResponseCreateParamsBase(TypedDict, total=False):
background: Optional[bool]
context_management: Optional[Iterable[ContextManagement]]
conversation: Optional[Conversation]
include: Optional[List[ResponseIncludable]]
input: Union[str, ResponseInputParam]
instructions: Optional[str]
max_output_tokens: Optional[int]
max_tool_calls: Optional[int]
metadata: Optional[Metadata]
model: ResponsesModel
parallel_tool_calls: Optional[bool]
previous_response_id: Optional[str]
prompt: Optional[ResponsePromptParam]
prompt_cache_key: str
prompt_cache_retention: Optional[Literal["in-memory", "24h"]]
reasoning: Optional[Reasoning]
safety_identifier: str
service_tier: Optional[Literal["auto", "default", "flex", "scale", "priority"]]
store: Optional[bool]
stream_options: Optional[StreamOptions]
temperature: Optional[float]
text: ResponseTextConfigParam
tool_choice: ToolChoice
tools: Iterable[ToolParam]
top_logprobs: Optional[int]
top_p: Optional[float]
truncation: Optional[Literal["auto", "disabled"]]
user: str
class ResponseCreateParamsNonStreaming(ResponseCreateParamsBase, total=False):
stream: Optional[Literal[False]]
class ResponseCreateParamsStreaming(ResponseCreateParamsBase):
stream: Required[Literal[True]]
ResponseCreateParams = Union[ResponseCreateParamsNonStreaming, ResponseCreateParamsStreaming]
Import
from openai.types.responses.response_create_params import (
ResponseCreateParamsBase,
ResponseCreateParamsNonStreaming,
ResponseCreateParamsStreaming,
)
# Or via the top-level re-export:
from openai.types.responses import ResponseCreateParams
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| model | ResponsesModel | No (total=False) | Model ID to use, e.g. "gpt-4o" or "o3"
|
| input | Union[str, ResponseInputParam] | No | Text, image, or file inputs to generate a response from |
| instructions | Optional[str] | No | System/developer message inserted into the model context |
| tools | Iterable[ToolParam] | No | Array of tools the model may call (functions, web search, MCP, etc.) |
| tool_choice | ToolChoice | No | How the model should select tools |
| temperature | Optional[float] | No | Sampling temperature between 0 and 2 |
| top_p | Optional[float] | No | Nucleus sampling probability mass |
| max_output_tokens | Optional[int] | No | Upper bound for generated tokens including reasoning tokens |
| max_tool_calls | Optional[int] | No | Maximum total built-in tool calls allowed |
| stream | Literal[True] / Optional[Literal[False]] | Varies | Controls streaming vs. non-streaming mode |
| store | Optional[bool] | No | Whether to store the response for later retrieval |
| previous_response_id | Optional[str] | No | ID of previous response for multi-turn conversations |
| conversation | Optional[Conversation] | No | Conversation reference for stateful interactions |
| truncation | Optional[Literal["auto", "disabled"]] | No | Truncation strategy for context overflow |
| reasoning | Optional[Reasoning] | No | Configuration for reasoning models (o-series, gpt-5) |
| service_tier | Optional[Literal["auto", "default", "flex", "scale", "priority"]] | No | Processing tier for the request |
| background | Optional[bool] | No | Whether to run the response in background mode |
| metadata | Optional[Metadata] | No | Up to 16 key-value pairs for object metadata |
| include | Optional[List[ResponseIncludable]] | No | Additional output data to include (sources, logprobs, etc.) |
| text | ResponseTextConfigParam | No | Configuration for text response format |
| prompt | Optional[ResponsePromptParam] | No | Reference to a reusable prompt template |
| prompt_cache_key | str | No | Cache key for prompt caching optimization |
| prompt_cache_retention | Optional[Literal["in-memory", "24h"]] | No | Retention policy for prompt cache |
| safety_identifier | str | No | Stable identifier for abuse detection |
| parallel_tool_calls | Optional[bool] | No | Whether to allow parallel tool execution |
| top_logprobs | Optional[int] | No | Number of most likely tokens to return (0-20) |
| user | str | No | Deprecated; replaced by safety_identifier and prompt_cache_key |
Outputs
| Name | Type | Description |
|---|---|---|
| ResponseCreateParamsBase | TypedDict | Base parameter dictionary with all shared fields |
| ResponseCreateParamsNonStreaming | TypedDict | Non-streaming variant (stream=False or omitted) |
| ResponseCreateParamsStreaming | TypedDict | Streaming variant (stream=True required) |
| ResponseCreateParams | Union | Union of streaming and non-streaming params |
| ToolChoice | TypeAlias | Union of ToolChoiceOptions, ToolChoiceAllowedParam, ToolChoiceFunctionParam, ToolChoiceMcpParam, ToolChoiceCustomParam, ToolChoiceApplyPatchParam, ToolChoiceShellParam, ToolChoiceTypesParam |
| Conversation | TypeAlias | Union[str, ResponseConversationParam] |
| StreamOptions | TypedDict | Streaming options with include_obfuscation flag |
| ContextManagement | TypedDict | Context management entry with type and compact_threshold |
Usage Examples
Basic Non-Streaming Request
from openai import OpenAI
from openai.types.responses import ResponseCreateParams
client = OpenAI()
response = client.responses.create(
model="gpt-4o",
input="Explain quantum computing in simple terms.",
instructions="You are a helpful science teacher.",
temperature=0.7,
max_output_tokens=500,
)
print(response.output)
Streaming Request
from openai import OpenAI
client = OpenAI()
stream = client.responses.create(
model="gpt-4o",
input="Write a short poem about Python programming.",
stream=True,
)
for event in stream:
print(event)
With Tools and Tool Choice
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-4o",
input="What is the weather in San Francisco?",
tools=[
{
"type": "function",
"name": "get_weather",
"description": "Get the current weather for a location.",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"},
},
"required": ["location"],
},
}
],
tool_choice="auto",
)