File Search Tool in combination with response schema not working

Using the file search tool, File Search store and response schema does not work. model answers only with text attribute, response is not parse, model states it canot answer questions about infromation in File Search store. Example:

from pydantic import BaseModel

class Response(BaseModel):
    answer: str
    files_used: list[str]

response_schema = Response.model_json_schema()

response = client.models.generate_content(
        model="gemini-2.5-flash-lite",
contents="""What is the color. of the moon?""",
config=types.GenerateContentConfig(
system_instruction="Use for file search tool only to answer the question. you must always try to provide an answer from the files.",
tools=[
types.Tool(
file_search=types.FileSearch(
file_search_store_names=[store.name], top_k=10
                    )
                )
            ],
response_mime_type="application/json",
response_schema=response_schema,
        ),
    )

response.parsed -> None
reponse.text -> 'Here is the JSON requested:\n```json\n{\n "answer": "I need more information to answer your question....

W/o schema it works.

According to https://ai.google.dev/gemini-api/docs/structured-output?example=recipe#structured_outputs_with_tools, structured output + tools ā€œis a feature available only with the gemini-3-pro-preview model.ā€ So you might try using that instead of flash lite.

.. Although file search may not be one of the supported tools, frustratingly. I got this error when trying it myself: ā€œFile Search tool with a response mime type: ā€˜application/json’ is unsupportedā€

This used to work with gemini-3-pro-preview a few days ago.. I’ve been building a NotebookLM inspired doc editor for the past couple of weeks which used this heavily, and it’s suddenly stopped working. Annoying!

Structured output + file search worked in gemini-3-pro-preview a few days ago for me, too. But alas, no longer.

The particularly vexing part is that file search was PREVIOUSLY listed as supported here - but has apparently since been removed.

Thank you for posting this. I was going crazy as I thought I was doing something wrong! This feature was working a few days ago. Very annoying.

Same thing happening to me :frowning: Was relying on this feature!

Same for me my solution file search with json response works some days ago with 2.5 preview model ā€˜gemini-2.5-flash-preview-09-2025’ and now my solution didn’t work anymore. Has anybody a feedback from Google or a solution for this?

I have contacted the API Lead on X about this and he is ā€œcheckingā€. Will let you know if I hear anything.

1 Like

Hello everyone, thank you for sharing your experiences with Gemini. I wanted to clarify the current support for using the File Search tool in combination with Response Schema. As of today, this workflow is functioning correctly with gemini-3-pro-preview, but please note that it is not currently supported in gemini-2.5-flash.

1 Like