responseJsonSchema expands json schema, making token size reach 100x its normal size

i am using responseJsonSchema to pass a json schema, that is 148059 characters long, it’s highly optimized by using $ref and $def, but I keep getting error 400

The input token count (8113056) exceeds the maximum number of tokens allowed (1048576).

even with a prompt that contains 3 words and candidate count = 1.

the only logical reason as to why this happens is if the gemini API did some processing on the json schema and expanded it to remove $refs, leading to duplicate schemas and increasing token usage to almost 100x

Hi @ahmednfwela ,

Welcome to the Forum !!
Could you please let us know which Gemini model you are using?