Need help : Schema nesting depth error when using Gemini models via @ai-sdk/openai package #1557
Unanswered
Nilesh9106
asked this question in
Q&A
Replies: 1 comment
-
|
This feels like one of those cases where an OpenAI-compatible surface is close enough for simple calls but not neutral for advanced structured generation. If Portkey adds wrapper fields or transforms the schema before it reaches Gemini, the effective nesting depth can exceed what your original zod schema suggests. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When using the Portkey OpenAI-compatible gateway to call Gemini models, complex JSON schemas trigger a Google API error: "A schema in GenerationConfig in the request exceeds the maximum allowed nesting depth."
The schema provided has 4 levels of nesting . While this is technically within Gemini's limit, the OpenAI-to-Gemini translation layer in Portkey likely wraps the schema in additional object properties. This same code works fine when used
@ai-sdk/googlepackage.I am not able to use the gemini model because of this, I cant use portkey for some of the model and direct provider for some of the models. either use portkey for all or dont use.
Relevant Code Snippet
Beta Was this translation helpful? Give feedback.
All reactions