openai/openai-python · error · ValueError
input must be provided when creating a new response
Error message
input must be provided when creating a new response
What it means
Raised by Responses.stream() when you pass new-response arguments (e.g. model) but omit `input`. A streaming response creation requires an input payload; without it the SDK cannot construct the create request, so it fails before any network call.
Source
Thrown at src/openai/resources/responses/responses.py:1222
"text": text,
"tool_choice": tool_choice,
"top_logprobs": top_logprobs,
"top_p": top_p,
"truncation": truncation,
"user": user,
"background": background,
}
new_response_args_names = [k for k, v in new_response_args.items() if is_given(v)]
if (is_given(response_id) or is_given(starting_after)) and len(new_response_args_names) > 0:
raise ValueError(
"Cannot provide both response_id/starting_after can't be provided together with "
+ ", ".join(new_response_args_names)
)
tools = _make_tools(tools)
if len(new_response_args_names) > 0:
if not is_given(input):
raise ValueError("input must be provided when creating a new response")
if not is_given(model):
raise ValueError("model must be provided when creating a new response")
if is_given(text_format):
if not text:
text = {}
if "format" in text:
raise TypeError("Cannot mix and match text.format with text_format")
text = copy(text)
text["format"] = _type_to_text_format_param(text_format)
api_request: partial[Stream[ResponseStreamEvent]] = partial(
self.create,
input=input,
model=model,View on GitHub (pinned to 9917c6e28e)
Solutions
- Provide input: client.responses.stream(model=..., input="hello") or a list of input items
- If you meant to continue a previous conversation, use response_id (continuation mode) instead of re-sending model
- Ensure conditional input-building code always yields at least one item
Example fix
# before stream = client.responses.stream(model="gpt-4o") # after stream = client.responses.stream(model="gpt-4o", input="Summarize this transcript...")
Defensive patterns
Strategy: validation
Validate before calling
if input is None or (isinstance(input, list) and not input):
if response_id is None:
raise ValueError("input is required to create a new streamed response") Type guard
def has_stream_input(input) -> bool:
return bool(input is not None) and (not isinstance(input, list) or len(input) > 0) Try / catch
try:
stream = client.responses.stream(model=model, input=input)
except ValueError as e:
if "input must be provided" in str(e):
input = build_default_input()
stream = client.responses.stream(model=model, input=input)
else:
raise Prevention
- Always pair model with input when creating
- Use response_id continuation instead of re-sending prompts for follow-ups
- Ensure conditional input builders never return empty
When it happens
Trigger: client.responses.stream(model="gpt-4o") with no input= argument (input defaults to NOT_GIVEN).
Common situations: Assuming a prompt from a previous turn persists (it does not — each create is stateless unless using previous_response_id), or building the input list conditionally and skipping it when empty.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- Cannot provide both response_id/starting_after can't be prov
- Didn't receive a `response.completed` event.
- Expected to have received `response.created` before `{event.
- Expected a non-empty value for `response_id` but received {r
- WebSocket connection closed with unsent messages
AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28).
Data as JSON: /api/errors/694b7df2d598561e.
Report an issue: GitHub.