Skip to content

Support responseSchema in VertexAiGeminiChatOptions #3765

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SuminAndrew
Copy link

Closes #2087

VertexAI's GenerationConfig natively uses a Schema object to configure response schema, which represents an OpenAPI schema. There's also a responseJsonSchema option, but it is only supported in Gemini 2.5 (see: https://ai.google.dev/gemini-api/docs/structured-output#json-schema).

To support this, I added a new String responseSchema property to VertexAiGeminiChatOptions. This allows users to provide an OpenAPI schema as a string, which is then converted into a Schema object internally. The same approach is already used for tool definitions via inputSchemas, so I extracted the conversion logic into a shared utility class. I also added corresponding unit tests.

@sobychacko
Copy link
Contributor

@SuminAndrew, could you sign your commit using DCO? https://spring.io/blog/2025/01/06/hello-dco-goodbye-cla-simplifying-contributions-to-spring

@SuminAndrew SuminAndrew force-pushed the support-gemini-response-schema branch 2 times, most recently from 931d6b6 to f8cc6d4 Compare July 8, 2025 15:57
@SuminAndrew
Copy link
Author

@SuminAndrew
Copy link
Author

Hey @sobychacko, I wonder what are the next steps for this PR? Should I tag someone to get this reviewed?

@SuminAndrew SuminAndrew force-pushed the support-gemini-response-schema branch from f8cc6d4 to 42e331b Compare July 14, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Json Schema with Gemini
2 participants