Skip to main content
Read the Notte skill and follow its setup instructions when setting up Notte or building browser automation. This is the shared source for CLI setup, authentication, and the browser-to-code workflow.
Agents can return structured data in a specific format using Pydantic models. The agent’s answer follows your model’s JSON schema, and you parse result.answer with the model to get typed, validated data.

Overview

By default, agents return unstructured text answers:
overview_default.py
With structured output, define the exact format you want:
overview_structured.py

Basic Example

Define a Pydantic model and pass it to response_format:

Complex Models

Nested Structures

Models can contain nested objects:
nested_structures.py

Lists of Objects

Extract multiple items:
lists_of_objects.py

Optional Fields

Use None for optional fields:

Use Cases

E-commerce Data Extraction

Extract structured product data:
ecommerce_extraction.py

Lead Generation

Extract structured contact information:
lead_generation.py

Job Listings

Extract job posting details:
job_listings.py

Social Media Data

Extract social media profiles:
social_media.py

Field Validation

Pydantic constraints and validators run when you parse result.answer on your side, not inside the agent. Use them to reject bad data:
field_validation.py

Best Practices

1. Be Specific in Task Description

Match your task to the response format:
bp_specific_task.py

2. Use Appropriate Types

Choose Python types that match the data:

3. Make Optional Fields Explicit

Don’t assume data will always be present:

4. Use Field Descriptions

Help the agent understand what you want:

5. Start Simple, Then Expand

Begin with basic models:

Error Handling

result.answer is a JSON string (or None if the agent failed). Handle parsing and validation errors when you load it into your model:
error_handling.py

Limitations

Not Suitable For

Structured output works best for data extraction, not for:
  • Open-ended creative tasks
  • Tasks requiring explanation or reasoning
  • When you want natural language responses
limitations_not_suitable.py

Complex Relationships

Very complex nested structures may be challenging:
limitations_complex.py

Next Steps

Configuration

Configure agent parameters

Lifecycle

Understand agent execution modes

Fetch

Alternative data extraction methods

Best Practices

Data extraction best practices