openai/openai-python · error · ValueError

response_id must be provided when streaming an existing resp

Error message

response_id must be provided when streaming an existing response

What it means

Async Responses.stream() raises this when you provide no create arguments and response_id is the Omit sentinel (explicitly omitted) — i.e. neither the create path nor the resume path can be taken. It is the resume-branch counterpart to the input/model checks.

Source

Thrown at src/openai/resources/responses/responses.py:3151

                top_p=top_p,
                truncation=truncation,
                user=user,
                background=background,
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
            )

            return AsyncResponseStreamManager(
                api_request,
                text_format=text_format,
                input_tools=tools,
                starting_after=None,
            )
        else:
            if isinstance(response_id, Omit):
                raise ValueError("response_id must be provided when streaming an existing response")

            api_request = self.retrieve(
                response_id,
                stream=True,
                include=include or [],
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
            )
            return AsyncResponseStreamManager(
                api_request,
                text_format=text_format,
                input_tools=tools,
                starting_after=starting_after if is_given(starting_after) else None,
            )

    async def parse(

View on GitHub (pinned to 9917c6e28e)

Solutions

  1. Pass a real response id: await client.responses.stream(response_id='resp_abc')
  2. Don't use Omit for response_id — omit the argument entirely or pass input+model to create
  3. Fix wrapper code that substitutes OMIT for missing ids

Example fix

// before
await client.responses.stream(response_id=OMIT)
// after
await client.responses.stream(response_id="resp_abc")
Defensive patterns

Strategy: validation

Validate before calling

if response_id is None or response_id is OMIT:
    raise ValueError('a real response id is required to resume streaming')
await client.responses.stream(response_id=response_id)

Type guard

def is_resume_id(response_id) -> bool:
    return isinstance(response_id, str) and bool(response_id.strip())

Try / catch

try:
    await client.responses.stream(response_id=rid)
except ValueError as e:
    if 'existing response' in str(e):
        rid = await lookup_latest_response_id()
        await client.responses.stream(response_id=rid)
    else:
        raise

Prevention

When it happens

Trigger: Calling async stream() with response_id explicitly set to Omit (e.g. OMIT constant from the SDK) and no new-response arguments; wrappers that forward an OMIT placeholder id.

Common situations: Using the SDK's Omit/OMIT sentinels for optional params and accidentally applying Omit to response_id while relying on resumption; generic parameter forwarding code.

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


AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28). Data as JSON: /api/errors/51099229043b6c68. Report an issue: GitHub.