Output response types are not usable as parameters
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 31.6k
- Forks
- 5.7k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 96
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
Consider the following code:
messages: ResponseInputParam = [{"role": "developer", "content": instructions}]
# ...
resp = client.responses.create(
model="o4-mini",
input=messages,
)
for item in resp.output:
match item:
case ResponseOutputMessage(content=content):
print(item.content)
messages.append(item)
This seems like it should work fine, but it generates a type checking error:
error: Argument of type "ResponseOutputMessage" cannot be assigned to parameter "object" of type "ResponseInputItemParam" in function "append"
Type "ResponseOutputMessage" is not assignable to type "ResponseInputItemParam"
"ResponseOutputMessage" is not assignable to "EasyInputMessageParam"
"ResponseOutputMessage" is not assignable to "Message"
"ResponseOutputMessage" is not assignable to "ResponseOutputMessageParam"
"ResponseOutputMessage" is not assignable to "ResponseFileSearchToolCallParam"
"ResponseOutputMessage" is not assignable to "ResponseComputerToolCallParam"
"ResponseOutputMessage" is not assignable to "ComputerCallOutput"
"ResponseOutputMessage" is not assignable to "ResponseFunctionWebSearchParam"
... (reportArgumentType)
I think this is because the parameter types use Required, but the output types don't. For example, EasyMessageInputParam requires content, but ResponseOutputMessage doesn't:
vs
I recognize that the bindings are auto-generated and this may not be trivial to fix.
To Reproduce
n/a
Code snippets
OS
linux
Python version
Python v3.13.2
Library version
openai v1.75.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing src/openai/types/responses/easy_input_message_param.py and src/openai/types/responses/response_output_message.py, focusing on the required fields described in the report. Trace how these auto-generated types are produced before deciding where the compatibility change belongs. Done means the reported messages.append(item) pattern passes Python type checking without weakening the intended response and input type requirements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100