Skip to content

Conversation

@yukukotani
Copy link
Contributor

Currently, withStructuredOutput in langchain-google-genai (Gemini API) supports jsonSchema method, which is using native structured output.

While that, langchain-google-common (which is used by langchain-google-vertexai) supports only functionCalling method.

This PR adds jsonSchema method support to langchain-google-common. The implementation is mostly modeled after langchain-google-genai.

…ogle-common

- Add responseSchema property to GoogleAIModelRequestParams and GeminiGenerationConfig
- Update withStructuredOutput to support both jsonSchema (default) and functionCalling methods
- Add responseSchema handling in formatGenerationConfig to set responseMimeType to application/json
- Update copyAIModelParamsInto to copy responseSchema
- Add comprehensive tests for jsonSchema method support
- Update error message to reflect supported methods
@changeset-bot
Copy link

changeset-bot bot commented Nov 30, 2025

🦋 Changeset detected

Latest commit: 093037b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@langchain/google-common Minor
@langchain/google-gauth Minor
@langchain/google-vertexai-web Minor
@langchain/google-vertexai Minor
@langchain/google-webauth Minor
@langchain/google-genai Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment on lines +1780 to +1781
// Not specifying method - should default to jsonSchema
const model = baseModel.withStructuredOutput(schema);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using jsonSchema method by default. This is the same behaviour as langchain-google-genai, but might be a breaking change for langchain-google-vertexai users.

I would like to have an opinion of maintainers.

@yukukotani yukukotani changed the title Add jsonSchema method support to withStructuredOutput in langchain-google-common and VertexAI feat(langchain-google-common): Add jsonSchema method support to withStructuredOutput in langchain-google-common and VertexAI Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant