Hello,
I’m trying to set up structured output in gemini-2.5-flash-lite batch mode using file input (python). In inline input you can pass pydantic object with 'response_schema': list[Recipe] (like this) which works, but what is the proper way of passing the structured output schema when using input file? I tried passing JSON Schema but it didn’t seem to work?? As stated in docs it should work with gemini-2.5, does it include gemini-2.5-flash-lite?
Here is what I’m trying to achieve
CATEGORIES = ["Polityka", "Gospodarka", "Świat", "Kultura", "Sport", "Nauka", "Technologia", "Kraj", "Edukacja", "Inne"]
class Summary(BaseModel):
title: str
snippet: str
bulletPoints: List[str]
categories: List[Literal[CATEGORIES]]
. . .
inline_requests.append(
{
"key": cluster.get("cluster_id"),
"request": {
"contents": [
{
"parts": [{"text": prompt}],
"role": "user",
}
]
},
"generationConfig": {
"response_mime_type": "application/json",
"response_schema": Summary.model_json_schema(),
}
}
)
. . .
As I stated, I tried different approaches:
- Passing
pydanticobject - passing
Summary.model_json_schema()to theresponseJsonSchemafield - passing
Summary.model_json_schema()to a normalresponse_schemafield - passing a dictionary
Also I didn’t find information about the name of the field that needs to be set in the request? responseSchema has response_schema field but I found that only in the provided examples, there is no example on responseJsonSchema. Is it response_json_schema? It didn’t work both ways though.
I have noticed now that generationConfig should be generation_config instead? Still didn’t work