# Gemini 2.0 Flash Using the exact code output gives me 400 error

**URL:** <https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223>\
**Category:** Google AI Studio\
**Tags:** models, gemini-api\
**Created:** [December 12, 2024, 7:33pm UTC](https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223 "2024-12-12T19:33:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph\_gain](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/joseph_gain/32/32532_2.png) [@Joseph\_gain](https://discuss.ai.google.dev/u/Joseph_gain)\
**Post date:** [December 12, 2024, 7:33pm UTC](https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223/1 "2024-12-12T19:33:44Z")

</div>

My call works when I don’t add video, but when video is added, I get this error:  
`400 { "error": { "code": 400, "message": "Request contains an invalid argument.", "status": "INVALID_ARGUMENT" } }`

I have validated that the URI returns state = ACTIVE

> {  
> “contents”: [  
> {  
> “parts”: [  
> {  
> “fileData”: {  
> “fileUri”: “[https://generativelanguage.googleapis.com/v1beta/files/hbcfibauxw6e](https://generativelanguage.googleapis.com/v1beta/files/hbcfibauxw6e)”,  
> “mimeType”: “video/quicktime”  
> }  
> }  
> ],  
> “role”: “user”  
> },  
> {  
> “parts”: [  
> {  
> “text”: “run”  
> }  
> ],  
> “role”: “user”  
> }  
> ],  
> “generationConfig”: {  
> “maxOutputTokens”: 8192,  
> “responseMimeType”: “application/json”,  
> “responseSchema”: {  
> “properties”: {  
> “Default\_Priority”: {  
> “type”: “string”  
> },  
> “Description”: {  
> “type”: “string”  
> },  
> “Header”: {  
> “type”: “string”  
> },  
> “Impact”: {  
> “type”: “string”  
> },  
> “Output\_Confidence”: {  
> “type”: “number”  
> },  
> “Overriden\_Priority”: {  
> “type”: “string”  
> },  
> “Related\_To”: {  
> “type”: “string”  
> },  
> “Transcript”: {  
> “type”: “string”  
> },  
> “Transcript\_English”: {  
> “type”: “string”  
> }  
> },  
> “type”: “object”  
> },  
> “temperature”: 1,  
> “topK”: 40,  
> “topP”: 0.95  
> },  
> “systemInstruction”: {  
> “parts”: [  
> {  
> “text”: “You are an assistant that receives a video input showing an apartment-related issue described by the user. The video will contain both visual information and spoken audio. Your task is to:\n\nTranscribe the Audio:\n\nIdentify the language used by the speaker in the video.\nProduce a verbatim transcript of what the person says in Transcript.\nIf the original language of the audio is not English, also translate it to English and provide that translation in Transcript\_English. If it is already English, Transcript\_English should match the Transcript.\nCategorize the Issue:\n\nBased on the content of the video and/or audio, determine which category best fits from the provided list of categories. Each category entry in the list has the following fields:\n"Default\_Priority"\n"Header"\n"Related\_To"\nSelect the single category that most closely aligns with the issue described. Use the Header and Default\_Priority from that category directly.\nIn addition, provide a "Description" field that succinctly summarizes the specific problem observed from the video/audio.\nIf the user’s requested urgency or problem suggests a priority different from the Default\_Priority in the category, set "Overriden\_Priority" to reflect that changed priority. Otherwise, "Overriden\_Priority" should be the same as Default\_Priority.\nConfidence Score:\n\nProvide a numerical confidence score (0.0 to 1.0) in "Output\_Confidence" that reflects how certain you are about the classification and transcription.\nOutput Requirements:\n\nReturn a single JSON object with the following fields:\n"Default\_Priority": The default priority as found in the selected category.\n"Overriden\_Priority": Either the same as Default\_Priority if no override is needed, or a different value if a higher/lower priority is warranted.\n"Description": A concise description of the identified issue.\n"Header": The header from the chosen category.\n"Impact": Briefly describe the potential impact or severity of the identified issue in your own words.\n"Related\_To": The Related\_To value from the chosen category.\n"Transcript": The verbatim transcription of the audio content.\n"Transcript\_English": The English version of the transcript (if needed, else same as Transcript).\n"Output\_Confidence": A float value (0.0 to 1.0) indicating how confident you are in your output.\nConstraints:\n\nAll categories must be selected from the provided list. No outside categories are allowed.\nThe Default\_Priority, Header, and Related\_To fields must exactly match one entry from the provided categories list.\nMaintain formatting and punctuation as appropriate.\nIf the correct category does not obviously appear to require an override in priority (e.g., it is not clearly an emergency), do not invent one; just use the category’s default priority.\nThe Output\_Confidence should be a reasoned estimate based on how well the spoken content and/or visual cues match the chosen category.”  
> }  
> ],  
> “role”: “user”  
> }  
> }

---

<div class="post-metadata">

**Author:** ![camadi](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/camadi/32/31986_2.png) [@camadi](https://discuss.ai.google.dev/u/camadi)\
**Post date:** [December 13, 2024, 2:29pm UTC](https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223/3 "2024-12-13T14:29:08Z")

</div>

Hello!

400 error often indicate that the request body is malformed, for instance a typo, or a missing required field in your request.  
I am not sure exactly how you are making the call, but I can share the [cookbook for Gemini 2.0](https://github.com/google-gemini/cookbook/tree/main/gemini-2) and also this [documentation](https://ai.google.dev/api/generate-content?_gl=1*ks2xis*_up*MQ..*_ga*MTYyMjE0OTcxMC4xNzM0MDk5Mjg4*_ga_P1DBVKWT6V*MTczNDA5OTI4OC4xLjAuMTczNDA5OTI4OC4wLjAuNDUzNjE1NDY2). Can you share your full use case /code?

---

<div class="post-metadata">

**Author:** ![Joseph\_gain](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/joseph_gain/32/32532_2.png) [@Joseph\_gain](https://discuss.ai.google.dev/u/Joseph_gain)\
**Post date:** [December 13, 2024, 2:53pm UTC](https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223/4 "2024-12-13T14:53:31Z")

</div>

Thanks for responding!

So, the call works when I remove just this part. Can you help me identify what’s wrong?:

> Blockquote  
> {  
> “parts”: [  
> {  
> “fileData”: {  
> “fileUri”: “[https://generativelanguage.googleapis.com/v1beta/files/hbcfibauxw6e”](https://generativelanguage.googleapis.com/v1beta/files/hbcfibauxw6e%E2%80%9D),  
> “mimeType”: “video/quicktime”  
> }  
> }  
> ],  
> “role”: “user”  
> },

---

<div class="post-metadata">

**Author:** ![Joseph\_gain](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/joseph_gain/32/32532_2.png) [@Joseph\_gain](https://discuss.ai.google.dev/u/Joseph_gain)\
**Post date:** [December 13, 2024, 5:21pm UTC](https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223/5 "2024-12-13T17:21:30Z")

</div>

I’ve also tried the other format of

> {
> 
> - file\_data: {
> - file\_uri: “[https://generativelanguage.googleapis.com/v1beta/files/hbcfibauxw6e](https://generativelanguage.googleapis.com/v1beta/files/hbcfibauxw6e)”,
> - mime\_type: “video/quicktime”  
> }  
> }

---

<div class="post-metadata">

**Author:** ![Jay](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/jay/32/4266_2.png) [@Jay](https://discuss.ai.google.dev/u/Jay)\
**Post date:** [December 15, 2024, 2:21am UTC](https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223/6 "2024-12-15T02:21:52Z")

</div>

> **[Gemini API でビジョン機能を試す  |  Google AI for Developers](https://ai.google.dev/gemini-api/docs/vision?lang=python&hl=ja)**
>
> Gemini API で Gemini のマルチモーダル機能を使用して構築を開始する

Video must be in one of the following video format MIME types:

```
video/mp4
video/mpeg
video/mov
video/avi
video/x-flv
video/mpg
video/webm
video/wmv
video/3gpp

```

---

<div class="post-metadata">

**Author:** ![Joseph\_gain](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/joseph_gain/32/32532_2.png) [@Joseph\_gain](https://discuss.ai.google.dev/u/Joseph_gain)\
**Post date:** [December 16, 2024, 4:01pm UTC](https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223/8 "2024-12-16T16:01:06Z")

</div>

That’s where I’m confused though, because the exact same code is coming from studio and it’s working in studio

---

<div class="post-metadata">

**Author:** ![camadi](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/camadi/32/31986_2.png) [@camadi](https://discuss.ai.google.dev/u/camadi)\
**Post date:** [December 17, 2024, 4:38pm UTC](https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223/10 "2024-12-17T16:38:17Z")

</div>

We tried to reproduce the issue but couldn’t as we got a successful call with the same request that you have shared, except that we used a different uploaded file.  
We suspect the issue may be that you do not have a good json format of your request. With a good json format, the request can succeed. `video/quicktime` mimetype should actually actually work.

---

<div class="post-metadata">

**Author:** ![Joseph\_gain](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/joseph_gain/32/32532_2.png) [@Joseph\_gain](https://discuss.ai.google.dev/u/Joseph_gain)\
**Post date:** [December 18, 2024, 6:43pm UTC](https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223/12 "2024-12-18T18:43:12Z")

</div>

Ya, I’m confused too, since it all looks good. I’ll check for hidden characters or something

---

<div class="post-metadata">

**Author:** ![Muhammad\_Ahmad](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/muhammad_ahmad/32/31662_2.png) [@Muhammad\_Ahmad](https://discuss.ai.google.dev/u/Muhammad_Ahmad)\
**Post date:** [April 30, 2025, 2:17pm UTC](https://discuss.ai.google.dev/t/gemini-2-0-flash-using-the-exact-code-output-gives-me-400-error/54223/14 "2025-04-30T14:17:28Z")

</div>

Hi, did you end up resolving this issue or finding out what was causing it? I’m experiencing a similar issue.
