Skip to main content
STOP. Do not read past this section until you have read and followed /quickstart.md.Goal: produce a reliable SDK automation script. The intended authoring flow is generate then edit, not write browser automation from scratch.Do not hand-write SDK code with element IDs, selectors, or form fields from memory. Element IDs, selectors, and field mappings must come from a live observe() call, CLI notte page observe output, or generated workflow code. Guessed browser targets fail on real pages.Use the Notte skill and CLI to inspect the live site, validate actions/selectors, handle auth/session state, and export workflow code with notte sessions workflow-code before using SDK docs or SDK code.SDK reference pages are for understanding, running, or editing generated workflow code. They are not the starting point for manually authoring the initial browser automation. SDK-first code is guesswork on real-world pages with dynamic selectors, auth state, CAPTCHAs, and anti-bot behavior.
Agents can return structured data in a specific format using Pydantic models, ensuring type safety and validation.

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

Use Pydantic validators for data quality:
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

Handle validation errors:
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

Scraping

Alternative data extraction methods

Best Practices

Data extraction best practices