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....
.. 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!
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?
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.