Error Uploading ZIP File via API: MimeType 'application/zip' Not Supported

Hello,
I am working on a project to analyze my codebase. I can upload a ZIP file via the AI Studio web interface and analyze the contents without issues. However, when I try to upload the ZIP file using the API, I encounter the following error:

“Unable to submit request because it has a mimeType parameter with value application/zip, which is not supported.”

Has anyone faced this problem or know how to resolve it? Any help would be greatly appreciated!

Example code:

import base64
import os
from google import genai
from google.genai import types


def generate():
    client = genai.Client(
        api_key=os.environ.get("GEMINI_API_KEY"),
    )

    files = [
        # Make the file available in local system working directory
        client.files.upload(file="main.zip"),
    ]
    model = "gemini-2.0-flash"
    contents = [
        types.Content(
            role="user",
            parts=[
                types.Part.from_uri(
                    file_uri=files[0].uri,
                    mime_type=files[0].mime_type,
                ),
                types.Part.from_text(text="""INSERT_INPUT_HERE"""),
            ],
        ),
    ]
    generate_content_config = types.GenerateContentConfig(
        temperature=1,
        top_p=0.95,
        top_k=40,
        max_output_tokens=8192,
        response_mime_type="text/plain",
    )

    for chunk in client.models.generate_content_stream(
        model=model,
        contents=contents,
        config=generate_content_config,
    ):
        print(chunk.text, end="")

if __name__ == "__main__":
    generate()
1 Like

Hi @Ismail_Kundakci, Welcome to the forum!!!

Are you sure you can upload and analyze zip file in AI Studio?? Zip file is not supported in AI Studio as well. I checked again, it’s throwing error.

1 Like