859 B
859 B
| description |
|---|
| A simple Pydantic AI example that constructs a validated Pydantic model from free-form text input, using structured output with any supported model. |
Pydantic Model
Simple example of using Pydantic AI to construct a Pydantic model from a text input.
Demonstrates:
Running the Example
With dependencies installed and environment variables set, run:
python/uv-run -m pydantic_ai_examples.pydantic_model
This example uses an OpenAI model by default. To run it with Gemini, set PYDANTIC_AI_MODEL to a model ID with the google: prefix.
PYDANTIC_AI_MODEL="{{ google:medium }}" python/uv-run -m pydantic_ai_examples.pydantic_model
Example Code
snippet {path="/examples/pydantic_ai_examples/pydantic_model.py"}