Skip to main content
Start with the offline examples from the source checkout. They use no API credentials or external model service.

Validate and correct a result

Source: crates/rydantic-ai/examples/typed_agent.rs
Returns a typed support decision after one intentionally invalid response. Expect model_calls=2 total_tokens=30; those token counts are demonstration data. The typed-agent tutorial explains the provider, schema and retry limits.

Stream partial objects and lists

Source: crates/rydantic-ai/examples/structured.rs
Prints partial previews, one accepted person and two list items. The streaming tutorial explains attempt resets and final acceptance.

Pause and resume a graph

Source: crates/rydantic-ai/examples/graph.rs
Pauses after incrementing a value, serializes a checkpoint, restores it and finishes the graph. Expect output=42, steps=2.

Call an API with a typed tool

Source: crates/rydantic-ai/examples/provider.rs Configure BASEURL, MODEL and optional APIKEY in your environment. Select the API protocol:
The agent exposes a typed add tool and asks the model to compute 19 + 23. The final output is validated, and the program prints call and usage counters. Live output depends on the configured model and its tool capabilities. See API providers.

Describe an image

Source: crates/rydantic-ai/examples/vision.rs With a configured image-capable model and a local image:
Prints a validated textual description. API=chat_completions and API=anthropic_messages use the other supported protocols. See image inputs for media types and limits.

Summarize a PDF

Source: crates/rydantic-ai/examples/pdf.rs With a configured document-capable model and a local PDF:
Embeds the file and prints a validated summary. All three protocols support embedded PDF inputs in the development source. This example accompanies the PDF development guide; it is not included in the published RydanticAI 0.6.0 release.

Ask TypeSafe Jev typed questions

Source: crates/rydantic-ai/examples/jev.rs Set both TYPESAFE_BASEURL and TYPESAFE_APIKEY locally, then run:
Combines Noul, Choice and Score questions for a support ticket, validates the decision and prints the response. Read the Jev SDK guide for question semantics and result types.