on-internet
← Community

How to ensure default values in Gemini/Vertex structured output?

Stack Overflow ·

When sending a prompt with a schema/json schema, I'd like to ensure that some values would be always present with a default if they are not mentioned in the prompt. Both Gemini API and Vertex API accept Schema and JSON Schema, but I couldn't find in the docs how default values are treated. Note: I am using google.genai sdk and pydantic for simplicity, but the idea is the same for a REST call and for the Vertex API. In the example below, I'm setting the default values: flag = False, op = "all" and min_value = 42. But default values are not present in the required field of the schema (Foo.model_

Comments

Sign in or sign up to comment and upvote.

No comments yet.