# File API Unexpected 400 error in response stream

**URL:** <https://discuss.ai.google.dev/t/file-api-unexpected-400-error-in-response-stream/109131>\
**Category:** Gemini API\
**Tags:** api\
**Created:** [November 9, 2025, 11:46am UTC](https://discuss.ai.google.dev/t/file-api-unexpected-400-error-in-response-stream/109131 "2025-11-09T11:46:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michiel\_Pronk](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/michiel_pronk/32/34142_2.png) [@Michiel\_Pronk](https://discuss.ai.google.dev/u/Michiel_Pronk)\
**Post date:** [November 9, 2025, 11:46am UTC](https://discuss.ai.google.dev/t/file-api-unexpected-400-error-in-response-stream/109131/1 "2025-11-09T11:46:42Z")

</div>

I am trying to upload a jsonl file for batch processing in the File API. Unfortunately, the file is never returned in the API response. Instead I get the following response:  
`{‘headers’: {‘content-type’: ‘application/json; charset=UTF-8’, ‘x-guploader-uploadid’: ‘XXX’, ‘x-goog-upload-status’: ‘final’, ‘vary’: ‘Origin, X-Origin, Referer’, ‘content-length’: ‘118’, ‘date’: ‘Sun, 09 Nov 2025 11:30:44 GMT’, ‘server’: ‘UploadServer’, ‘alt-svc’: ‘h3=“:443”; ma=2592000,h3-29=“:443”; ma=2592000’}, ‘status_code’: 200, ‘response_stream’: [‘{\n “error”: {\n “code”: 400,\n “message”: “Unsupported MIME type: jsonl”,\n “status”: “INVALID_ARGUMENT”\n }\n}\n’], ‘byte_stream’: None}`

I couldn’t find any invalid arguments in my jsonl and uploading it as json gave the same error. I also tried the example code from the [documentation](https://ai.google.dev/gemini-api/docs/batch-api#python_1) which also didn’t work. Is this an issue on Google’s part?

---

<div class="post-metadata">

**Author:** ![Shivam\_Singh2](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/shivam_singh2/32/31553_2.png) [@Shivam\_Singh2](https://discuss.ai.google.dev/u/Shivam_Singh2)\
**Post date:** [November 10, 2025, 6:03am UTC](https://discuss.ai.google.dev/t/file-api-unexpected-400-error-in-response-stream/109131/3 "2025-11-10T06:03:52Z")

</div>

Hi @Michiel_Pronk  
Welcome to Google AI Forum!!

Thank you for bringing this to our attention. Could you please share the full payload details along with a sample of the code that you are using? We would like to reproduce the issue.

---

<div class="post-metadata">

**Author:** ![Foxdiddy](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/foxdiddy/32/77979_2.png) [@Foxdiddy](https://discuss.ai.google.dev/u/Foxdiddy)\
**Post date:** [December 19, 2025, 3:04am UTC](https://discuss.ai.google.dev/t/file-api-unexpected-400-error-in-response-stream/109131/5 "2025-12-19T03:04:32Z")

</div>

Was there a solution to this??

I’m having the same issue.

index):123 Uncaught TypeError: Cannot read properties of undefined (reading ‘register’)  
at (index):123:28  
[generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent:1](http://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent:1) Failed to load resource: the server responded with a status of 400 ()  
geminiService.ts:147 Valuation Assessment Error: ApiError: {“error”:{“code”:400,“message”:“API key not valid. Please pass a valid API key.”,“status”:“INVALID\_ARGUMENT”,“details”:[{“@type”:“[type.googleapis.com/google.rpc.ErrorInfo",“reason”:“API\_KEY\_INVALID”,“domain”:“googleapis.com”,“metadata”:{“service”:“generativelanguage.googleapis.com”}},{“@type”:“type.googleapis.com/google.rpc.LocalizedMessage”,“locale”:“en-US”,“message”:"API](http://type.googleapis.com/google.rpc.ErrorInfo%22,%E2%80%9Creason%E2%80%9D:%E2%80%9CAPI_KEY_INVALID%E2%80%9D,%E2%80%9Cdomain%E2%80%9D:%E2%80%9Cgoogleapis.com%E2%80%9D,%E2%80%9Cmetadata%E2%80%9D:%7B%E2%80%9Cservice%E2%80%9D:%E2%80%9Cgenerativelanguage.googleapis.com%E2%80%9D%7D%7D,%7B%E2%80%9C@type%E2%80%9D:%E2%80%9Ctype.googleapis.com/google.rpc.LocalizedMessage%E2%80%9D,%E2%80%9Clocale%E2%80%9D:%E2%80%9Cen-US%E2%80%9D,%E2%80%9Cmessage%E2%80%9D:%22API) key not valid. Please pass a valid API key.”}]}}  
at throwErrorIfNotOK (\_api\_client.ts:860:24)  
at async \_api\_client.ts:493:9  
at async Models.generateContent (models.ts:69:14)  
at async geminiService.ts:96:28  
at async geminiService.ts:21:36  
at async SearchQueue.process (geminiService.ts:49:17)  
(anonymous) @ geminiService.ts:147  
(index):47 [SearchQueue]

The API key works just fine as long as I am within the Google AI Studio environment. As soon as I exit that environment, I get 400 and 409 errors.
