Quick Start
How It Works
| Phase | What happens |
|---|---|
| 1. Request | You pass a Pydantic model to output_pydantic |
| 2. Generate | The agent produces a response |
| 3. Validate | The response is checked against your schema |
| 4. Return | A typed object flows back to your code |
Native Structured Output
PraisonAI auto-detects models that support nativeresponse_format with JSON schema (GPT-4o, Claude 3.5, Gemini 2.0). Unsupported models fall back to prompt injection.
| Option | Type | Default | Description |
|---|---|---|---|
output_pydantic | BaseModel | None | Return a validated Pydantic object |
output_json | BaseModel | None | Return structured JSON (same schema) |
native_structured_output | bool | auto | Force native response_format on/off |
YAML Configuration
praisonai agents.yaml.
Best Practices
Keep models small and explicit
Keep models small and explicit
Define only the fields you need. Smaller schemas validate faster and reduce model confusion.
Prefer output_pydantic for Python apps
Prefer output_pydantic for Python apps
Use
output_pydantic when you want a typed object; use output_json when you only need serialisable dicts.Let native mode auto-detect
Let native mode auto-detect
Leave
native_structured_output unset unless you know your model needs forcing — the SDK picks the cleanest path.Validate failures in verbose mode
Validate failures in verbose mode
Enable verbose output while tuning schemas so validation errors show which field failed.
Related
Structured LLM Errors
Handle validation and LLM failures gracefully
Output & Display
Format and present agent responses
Agent Teams
Multi-agent workflows with structured tasks
Tasks
Task configuration and output options

