This feature is available for
Gemini 1.5 Pro & Gemini 1.5 Flash models.With Pydantic & Zod
The OpenAI SDKs for Python and JavaScript also make it easy to define object schemas using Pydantic and Zod respectively. Below, you can see how to extract information from unstructured text that conforms to a schema defined in code.- Zod with NodeJS
To use Zod with VerteX AI you will also need to import
{ zodResponseFormat } from openai/helpers/zodUsing Enums
You can also use enums to constrain the model’s output to a predefined set of values. This is particularly useful for classification tasks and multiple choice responses.Using JSON schema Directly
This method is more portable across different languages and doesn’t require additional libraries, but lacks the integrated type checking of the Pydantic/Zod approach. Choose the method that best fits your project’s needs.- cURL

