Skip to main content
Agents accept input and generate output in many formats, from simple strings to validated Pydantic models. Start with strings, add structure when you need validation.

Basic Usage

String in, string out:
from agno.agent import Agent
from agno.models.openai import OpenAIResponses

agent = Agent(model=OpenAIResponses(id="gpt-5.2"))

response = agent.run("What's the capital of France?")
print(response.content)  # "The capital of France is Paris."

Structured Input and Output

Use Pydantic models to validate what goes in and what comes back:
from pydantic import BaseModel, Field
from agno.agent import Agent
from agno.models.openai import OpenAIResponses

class ReviewInput(BaseModel):
    text: str
    product_id: str

class SentimentResult(BaseModel):
    sentiment: str = Field(description="positive, negative, or neutral")
    confidence: float = Field(ge=0, le=1)
    summary: str = Field(description="One sentence summary")

agent = Agent(
    model=OpenAIResponses(id="gpt-5.2"),
    output_schema=SentimentResult,
)

response = agent.run(
    input=ReviewInput(text="Love this product!", product_id="SKU-123")
)

result: SentimentResult = response.content
print(result.sentiment)   # "positive"
print(result.confidence)  # 0.95

When to Use Structured I/O

ScenarioRecommendation
Prototyping, chat interfacesStrings work fine
Data extraction, classificationStructured output
API responses, pipelinesStructured input and output

Guides