MIME type of Rich Text Format (RTF) inconsistent / wrong

Hi,

Following an issue reported for my Gemini SDK for .NET, I’m passing the underlying root cause to the Gemini API. Origin of problem and more info here: RTF file not supported by the API (UploadFile) · Issue #71 · mscraftsman/generative-ai · GitHub

What’s the problem?
The documentation stipulates that RTF content can be processed by Gemini models. See here: Explore document processing capabilities with the Gemini API  |  Google AI for Developers

However, the specified MIME type is text/rtf which according to the Mozilla Developer Network is not exactly correct and a lot of MIME type mappings are using the value application/rtf. See here: Common MIME types - HTTP | MDN

Interestingly, the File API does not care at all for the MIME type and accepts the RTF document. The following ingestion into Gemini gives the following HTTP 400 response.

{
  "error": {
    "code": 400,
    "message": "Unable to submit request because it has a mimeType parameter with value application/rtf, which is not supported. Update the mimeType and try again. Learn more: https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini",
    "status": "INVALID_ARGUMENT"
  }
}

I wrote a test case for my SDK showing this issue.

The same document has been uploaded twice to the File API - once using text/rtf and the other time using application/rtf.

This seems to be a deficit in the Gemini API not accepting the (more) correct MIME type of application/rtf.

Please have a look and escalate this to the team. Thanks.

Cheers

PS: @Vishal @GUNAND_MAYANGLAMBAM @Logan_Kilpatrick

Documentation issue hence tagging @kristen :wink:

Hey @jkirstaetter , Did you try uploading in AIStudio? It seems like the issue is happening only in the SDK.

Thanks for reporting the issue.

Hi @GUNAND_MAYANGLAMBAM

No, why would I try it in AI Studio when I need integration into my own applications?
Most likely AI Studio maps an RTF document to the MIME type text/rtf and it works. That’s how I implemented a workaround in my SDK to circumvent the improper MIME type.

As mentioned, according to MDN and other resources: application/rtf is the correct MIME type, and shall be accepted by the Gemini API.

Cheers.

PS: Did I post in the wrong section of the forum? Are the tags wrongly assigned? :wink:

Hello @GUNAND_MAYANGLAMBAM

Here’s a gist in Python using google-genai package producing the same HTTP 400 Bad Request when using the proper MIME type for a RTF document (application/rtf)

Hope this helps. Cheers

BTW,

Here’s the source code of nginx regarding the MIME types:

And alternatively, I found the following entries:

.rtf 	application/rtf
.rtf 	application/x-rtf
.rtf 	text/richtext

Source: An Alphebetized List of MIME Types

Other ref: Complete MIME Types List - FreeFormatter.com

According to IANA RTF uses both mime types: Media Types

It would be most appreciated that the Gemini API could stick with the official and widely accepted MIME types. And therefore accept both MIME types, not just the less common one.

Thanks.

1 Like

I have escalated this issue to the team.

1 Like