Nested objects
Lists of sub-objects work the same way. Define the inner model and reference it.output_schema=Meeting and the agent returns a Meeting with a populated action_items list.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Extract typed Pydantic objects from text, images, audio, video, and PDFs.
from typing import Optional
from agno.agent import Agent
from agno.models.google import Gemini
from pydantic import BaseModel, Field
class Contact(BaseModel):
name: Optional[str] = Field(None, description="Full name as written")
email: Optional[str] = Field(None, description="Email address")
phone: Optional[str] = Field(None, description="Phone number, raw format")
company: Optional[str] = Field(None, description="Company or organization")
title: Optional[str] = Field(None, description="Job title")
agent = Agent(
model=Gemini(id="gemini-3.5-flash"),
instructions=(
"Extract contact information from the input. Use exactly what the "
"text shows. If a field is missing, leave it null. Do not guess."
),
output_schema=Contact,
)
result = agent.run(
"Hi - Sarah Johnson, VP of Marketing at Acme Corp. "
"sarah@acme.com / +1-555-0102."
).content
# Contact(name='Sarah Johnson', email='sarah@acme.com',
# phone='+1-555-0102', company='Acme Corp.', title='VP of Marketing')
from typing import List, Optional
from pydantic import BaseModel, Field
class ActionItem(BaseModel):
owner: str = Field(..., description="Person responsible")
description: str = Field(..., description="What needs to be done")
due_date: Optional[str] = Field(None, description="Due date if stated")
class Meeting(BaseModel):
action_items: List[ActionItem] = Field(default_factory=list)
output_schema=Meeting and the agent returns a Meeting with a populated action_items list.
from typing import Literal, Optional
from agno.agent import Agent
from agno.models.google import Gemini
from pydantic import BaseModel, Field
class ConfidentField(BaseModel):
value: Optional[str] = None
confidence: Literal["high", "medium", "low"] = Field(
..., description="Confidence in the extracted value"
)
class Contact(BaseModel):
name: ConfidentField
email: ConfidentField
company: ConfidentField
instructions = """\
Extract contact information from the input. For each field:
- value: what the text shows; null if the field is missing
- confidence: high if explicit and unambiguous;
medium if implied or partially formatted;
low if guessed or ambiguous
Use exactly what the text shows. Do not normalize or paraphrase.
"""
confidence_agent = Agent(
model=Gemini(id="gemini-3.5-flash"),
instructions=instructions,
output_schema=Contact,
)
| Input | Argument | Cookbook |
|---|---|---|
| Text | agent.run(text) | text_extraction |
| Image | images=[Image(url=...)] | image_extraction |
| Audio | audio=[Audio(content=...)] | audio_extraction |
| Video | videos=[Video(content=..., format="mp4")] | video_extraction |
files=[File(url=...)] | document_extraction |
uv pip install lancedb tantivy
| Task | Guide |
|---|---|
| Assign labels | Classification |
| Build a searchable image library | Image Search |
| Feed non-text input | Multimodal inputs |
| Add a reviewer and adjudicator | Quality pipeline |
Was this page helpful?