Using ArkType with @google/genai
I had some trouble getting ArkType working with the latest Google AI SDK. Gemini complains about certain JSON Schema fields, so I had to remove them.
This seems to work for my use case:
Hope this saves someone some time!
2 Replies
There was also had an issue with the way
type.enumerated(...)
is converted to a JSON Schema, but I'm not encountering it now, I'll update later if I hit it again.It is is impossible when a JSON schema consumer has arbitrary restrictions that don't align with the spec to have output that would satisfy those constraints for all possible tools.
That said, we have made some changes in recent versions to use the most ubiquitous representations wherever possible wherever multiple are valid. If there are cases you find where we output something that could be simplified in a way that would be better understood by most tools, please open an issue so we can do that by default!
We also have lots of upcoming features in 2.2 for JSON schema generation that will help customize some of these behavior directly.
Thanks for posting this solution- hopefully if another Gemini users runs into the same issues, they will find this and/or I will point them to it 💓