File Search Tool in combination with response schema not working (original) (raw)
December 6, 2025, 5:17pm 1
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”
Jack_dev December 10, 2025, 6:27pm 6
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.
snowman December 12, 2025, 9:49am 10
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
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?
Jack_dev December 17, 2025, 9:06am 16
I have contacted the API Lead on X about this and he is “checking”. Will let you know if I hear anything.