Instructor & Pydantic Tooling
Structured data extraction & type-safe LLM function schemas
Instructor enforces strict Pydantic and Zod schemas on LLM outputs, turning unstructured web and API data into typed objects with automatic retries.
Quickstart Execution
extract.py
Get started with Instructor & Pydantic Tooling in your project.
import instructor
from openai import OpenAI
from pydantic import BaseModel
class DanishAddress(BaseModel):
street: str
house_number: str
postal_code: int
city: str
client = instructor.from_openai(OpenAI())
addr = client.chat.completions.create(
model="gpt-4o",
response_model=DanishAddress,
messages=[{"role": "user", "content": "Rådhuspladsen 1, 1550 København V"}],
)
print(addr.city)About Instructor & Pydantic Tooling
Instructor is the gold standard for getting structured, type-safe data out of LLMs. When parsing Danish government PDF reports, unstructured HTML, or legacy XML APIs, Instructor guarantees the response matches your schema with validation rules and automatic self-correction on error.
Danish Product & Data Recipes
How developers and agents use Instructor & Pydantic Tooling to connect with Danish digital infrastructure.
Extract Danish Company Accounting Metrics into Pydantic
Define a Pydantic schema for Danish solvency, EBITDA, and equity, and extract structured data directly from annual PDF reports.
from pydantic import BaseModel
import instructor
from openai import OpenAI
class DanishFinancials(BaseModel):
cvr: str
year: int
ebitda_dkk: float
equity_dkk: float
client = instructor.from_openai(OpenAI())
data = client.chat.completions.create(
model="gpt-4o",
response_model=DanishFinancials,
messages=[{"role": "user", "content": "Extract financials from this text..."}],
)