Using JSON Schema with Google Gemini

Back about a month ago, I wrote up a post on how to generate JSON results using Google Gemini, "JSON Results with Google Gemini Generative AI API Calls". While you should read that post first, the process basically boiled down to: Setting the response type of the result to JSON. Without this, Gemini will return JSON but encoded in Markdown. Using a System Instruction to give directions on the "shape" of the JSON, i.e., use this key and that key. While these techniques work well, recently yet another feature was added that makes this even better, JSON schema support. JSON Schema is an abstract way to define the shape of JSON and can be really useful in validation. The website... more →
Posted in: JavaScript