Why Does a Streaming Request Return 400 After a PDF Upload Succeeds?
Use the same file ID to test the upload, request format, and streaming path separately.
What the issue reported
A developer uploaded raw PDF bytes with the Python SDK and received a file ID. The follow-up request returned HTTP 400. The error pointed to file_id and said the expected PDF MIME type was unrecognized. That narrows the investigation, but the report alone does not establish where the file type was lost.
Get a minimal non-streaming request working first
- Use a small PDF you can open locally. Upload it with its .pdf filename intact and the user_data purpose, then note the returned file_id.
- For the Responses API, send the file as an input_file item with file_id on that item. Put your question in a separate input_text item. Disable streaming and use a model that supports PDF input.
- If you still get a 400, record the error parameter, error code, and request ID. Check the file fields actually sent, the selected model, and whether the upload and model request used the same service.
Enable streaming after the ordinary request succeeds
Change only the streaming flag. In the Responses API, read text increments from response.output_text.delta. If only the streamed request fails, note whether the server returned an HTTP error before opening the stream or sent an error event after it opened. Compare the direct and proxied paths if you use a proxy.
If both requests fail, investigate the file or request format first. If only the streamed request fails, inspect how the client and any intermediary handle the request and events.
FAQ
Does receiving a file_id mean I can use it in a model request?
Is adding a .pdf extension a confirmed fix?
References
Call these models through one gateway
Admesh provides a unified OpenAI-compatible API: one Base URL and one key for Claude, GPT, DeepSeek and more. New accounts get trial credit that never expires.
