openai/openai-python · error · ValueError
Cannot provide both response_id/starting_after can't be prov
Error message
Cannot provide both response_id/starting_after can't be provided together with ", ".join(new_response_args_names)
What it means
Raised by Responses.stream() when you mix continuation arguments (response_id or starting_after) with arguments that create a brand-new response (model, input, instructions, tools, etc.). The stream API supports two modes — resuming/forking an existing response or creating a new one — and supplying both is ambiguous, so the SDK raises ValueError listing the offending new-response args.
Source
Thrown at src/openai/resources/responses/responses.py:1215
"prompt_cache_retention": prompt_cache_retention,
"reasoning": reasoning,
"safety_identifier": safety_identifier,
"service_tier": service_tier,
"store": store,
"stream_options": stream_options,
"temperature": temperature,
"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")
View on GitHub (pinned to 9917c6e28e)
Solutions
- To continue/fork an existing response: remove model/input/etc. and pass only response_id (plus starting_after/output items as needed)
- To create a new streamed response: remove response_id and starting_after
- Audit the call site for leftover parameters from the other mode; the error message names the conflicting arguments
Example fix
# before
stream = client.responses.stream(
response_id="resp_123", model="gpt-4o", input="hi"
)
# after (continue existing)
stream = client.responses.stream(response_id="resp_123") Defensive patterns
Strategy: type-guard
Validate before calling
NEW_RESPONSE_ARGS = {"model", "input", "instructions", "tools", "temperature", "top_p", "max_output_tokens", "metadata", "text", "reasoning", "user", "background"}
continuing = response_id is not None or starting_after is not None
creating = any(kwargs.get(k) is not None for k in NEW_RESPONSE_ARGS)
if continuing and creating:
raise ValueError("pick one mode: response_id/starting_after OR new-response args") Type guard
def is_pure_continuation(response_id, starting_after, **new_args) -> bool:
given_new = [k for k, v in new_args.items() if v is not None]
return (response_id is not None or starting_after is not None) and not given_new Try / catch
try:
stream = client.responses.stream(**params)
except ValueError as e:
if "Cannot provide both" in str(e):
params.pop("response_id", None); params.pop("starting_after", None)
stream = client.responses.stream(**params)
else:
raise Prevention
- Wrap stream() calls in a small wrapper that enforces one mode
- Keep create-mode and continue-mode call sites separate
- Read the error message: it lists the conflicting arguments
When it happens
Trigger: client.responses.stream(response_id="resp_...", model="gpt-4o", input=[...]) — any of model/input/instructions/tools/temperature/... given together with response_id or starting_after.
Common situations: Refactoring code from create-then-stream to resume-style streaming while leaving old parameters in place; copy-pasting a full parameter set and adding response_id for retries.
Related errors
- input must be provided when creating a new response
- 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/24b345bb2defa7d9.
Report an issue: GitHub.