About gemini-2.5-flash API - Supported MIME types

Does text/plain refer only to .txt files, and not formats like .csv or .json?

If so, how do I go about it to maintain the structure of the object/data?

Hi @JasonYeo , Thanks for reaching out!

Yes, the API typically rejects application/json or text/csv for file uploads.

To fix this, upload your file content but explicitly set the mime_type to “text/plain”. The structure is perfectly preserved because the model reads the raw text characters (commas, brackets, indentation) and automatically parses them as structured data.

Thank you!

Hi @Srikanta_K_N, Thanks for replying.

I do have couple of follow-up questions.

1 Does mime_type “text/plain“ allow me to work with other file types like .docx, .xlsx and .csv?

2 Does the model allow me to use both “text/plain” and “image/png” together?

3 Is there a workaround for file size exceeding 50 MB other than splitting the files in chunk?

4 Can I reference the mime_type for text/plain based on the one used for image?**
“inlineData”: {**

                **"mimeType": "image/png",**

                **"data": b64,**

            **}**

Thanks you!

Hi @JasonYeo ,

  1. You actually can’t use text/plain for .docx or .xlsx files, since they’re compressed, the model will just see gibberish. It works fine for .csv because that’s just raw text, but for the rest, try to use the File API instead.
  2. Yes, the model is natively multimodal. You can mix and match text and files in the same request.
  3. It really depends on how big the data is. If it’s under 2 GB, the File API is the way. If you’re dealing with anything significantly larger, you’ll need to switch to a RAG approach so you aren’t hitting context limits.
  4. You can skip inlineData for your text content, that’s usually reserved for binary media (like images). For your prompts or raw CSV data, just use the standard text field in your JSON object to keep things simple.

Thank you!