instructor

Extract LLM response fields into validated Pydantic models with automatic retries.

Updated May 5, 2026
One-click install
npx skills add https://github.com/Z43L/zeus-agent --skill instructor-z43l
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: instructor
Source: https://github.com/Z43L/zeus-agent/tree/main/optional-skills/mlops/instructor
Command: npx skills add https://github.com/Z43L/zeus-agent --skill instructor-z43l

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires instructor, pydantic, openai, anthropic, and includes references (resource) components.

What problem does it solve?

Instructor removes the guesswork of getting reliable, machine-readable data from LLM responses by validating outputs against your Pydantic schemas and automatically retrying when extraction fails.

Core Features & Use Cases

  • Structured extraction with Pydantic validation: Convert free-form model text into strongly typed objects with automatic schema validation.
  • Automatic retries on validation errors: When fields don’t match your constraints, Instructor feeds back the validation error and tries again.
  • Type-safe parsing of complex JSON: Support nested models, enums, optional fields, and constrained values (e.g., ranges, formats).
  • Streaming partial results: Consume output incrementally for real-time UIs and progressive processing.
  • Multi-provider consistency: Use Instructor across common LLM providers while keeping the same structured-output workflow.

Quick Start

Use the instructor skill to extract a Person object from a message by providing a Pydantic model and asking the AI to return the needed fields (name, age, email).

Frequently Asked Questions about instructor

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract structured JSON from LLM responses reliably?

To extract structured JSON from LLM responses reliably, you can validate the model's text output against Pydantic schemas. This converts free-form text into strongly typed objects with automatic schema validation and nested type support.

How do I handle Pydantic validation errors during LM data extraction?

To handle Pydantic validation errors during data extraction, the workflow automatically feeds the validation error back to the LLM and retries the extraction. This automatic retry mechanism ensures the final output matches your defined constraints.

Can I stream partial structured JSON results from an LLM in real-time?

Yes, you can stream partial structured JSON results from an LLM in real-time. This allows you to consume output incrementally, enabling progressive processing and real-time UI updates as the model generates the typed data.

Does this structured extraction approach work with both OpenAI and Anthropic models?

Yes, structured extraction works with both OpenAI and Anthropic models. It provides multi-provider consistency, allowing you to use the same Pydantic response_model workflow across common LLM providers without changing your schema definitions.

What is the best way to parse complex JSON with nested models and enums from LLM output?

The best way to parse complex JSON with nested models, enums, and optional fields from LLM output is using type-safe Pydantic validation. This method supports constrained values like ranges and formats to ensure consistent structured data.

When do I need Pydantic schemas for LLM data extraction?

You need Pydantic schemas for LLM data extraction when your workflow requires consistent JSON for downstream automation. This is applicable for tasks like classification, entity extraction, and converting free-form text into machine-readable objects.