You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
types: Missing type for batch request input and output objects #1937
changed the title [-]Missing type for batch request input and output objects[/-][+]types: Missing type for batch request input and output objects[/+]on Dec 11, 2024
Yea, this caught me very off guard today. I did do the "thumbs up" thing, but it was surprising enough I went ahead and dropped a comment here as well. Not sure how this got missed...
Similar to the hint above, the body of the response is openai.types.Completion, but still have to manually define the other parts.
For batch_request_input.py with TypedDict class, in accordance with Batch API current supporting available endpoints docu, I will be adding custom_id, method (forcing with exactly the string "POST") using Literal, url, and body wrapping with BatchRequestBody using Union with current supporting things like below while adding fallback for any additional types
BatchRequestBody = Union[
ChatCompletionCreateParams,
CompletionCreateParams,
EmbeddingCreateParams,
ModerationCreateParams,
ResponseCreateParams,
Dict[str, Any], # Fallback for any additional types
]
On one hand, for batch_request_output.py with BaseModel class, I'm pretty sure there should be id, custom_id, response wrapping with BatchRequestOutputResponse using Union with current supporting things, including @shea-parkes mentioned Completion like below
# Note I used Union of specific response types since it's better than falling back to Dict[str, Any].
BatchResponseBody = Union[
ChatCompletion,
Completion,
CreateEmbeddingResponse,
ModerationCreateResponse,
Response,
]
and error wrapping with BatchRequestOutputError with current supporting things like code (Literal["batch_expired", "batch_cancelled", "request_timeout"]) and message referring to this document
If anyone is interested in trying this feature early using this git branch, your feedback would be greatly appreciated, @RobertCraigie, @alugowski, & @shea-parkes.! :))
Thanks for raising this, and thanks to everyone who contributed proposed types. The missing Batch JSONL record types need to be defined in the shared schema and exposed through SDK generation. openai/openai-openapi#578 tracks that work and links back to your report.
In the meantime, the Batch guide describes the record format and how to match results using custom_id. That provides a way to work with the files while the envelope types are missing. We’re closing this report to keep the work together in openai/openai-openapi#578; please follow that issue for the schema and SDK updates.
Activity
[-]Missing type for batch request input and output objects[/-][+]types: Missing type for batch request input and output objects[/+]re-typing inputs since OAI hasn't written the type in API
shea-parkes commentedon Nov 16, 2025
Yea, this caught me very off guard today. I did do the "thumbs up" thing, but it was surprising enough I went ahead and dropped a comment here as well. Not sure how this got missed...
Similar to the hint above, the
bodyof the response isopenai.types.Completion, but still have to manually define the other parts.NikkiAung commentedon Dec 30, 2025
For
batch_request_input.pywithTypedDictclass, in accordance with Batch API current supporting available endpoints docu, I will be addingcustom_id,method(forcing with exactly the string "POST") usingLiteral,url, andbodywrapping withBatchRequestBodyusing Union with current supporting things like below while adding fallback for any additional typesOn one hand, for
batch_request_output.pywithBaseModelclass, I'm pretty sure there should beid,custom_id,responsewrapping withBatchRequestOutputResponseusing Union with current supporting things, including @shea-parkes mentionedCompletionlike belowand
errorwrapping withBatchRequestOutputErrorwith current supporting things likecode(Literal["batch_expired", "batch_cancelled", "request_timeout"]) andmessagereferring to this documentIf anyone is interested in trying this feature early using this git branch, your feedback would be greatly appreciated, @RobertCraigie, @alugowski, & @shea-parkes.! :))
marcuswood-oai commentedon Sep 15, 2026
Thanks for raising this, and thanks to everyone who contributed proposed types. The missing Batch JSONL record types need to be defined in the shared schema and exposed through SDK generation. openai/openai-openapi#578 tracks that work and links back to your report.
In the meantime, the Batch guide describes the record format and how to match results using
custom_id. That provides a way to work with the files while the envelope types are missing. We’re closing this report to keep the work together in openai/openai-openapi#578; please follow that issue for the schema and SDK updates.