instructor

Extract structured data from LLM responses using Pydantic schemas with automatic validation retries.

Updated May 2, 2026
One-click install
npx skills add https://github.com/qcmuu/AI-Research-Skills --skill instructor-qcmuu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: instructor
Source: https://github.com/qcmuu/AI-Research-Skills/tree/main/16-prompt-engineering/instructor
Command: npx skills add https://github.com/qcmuu/AI-Research-Skills --skill instructor-qcmuu

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Instructor helps you turn messy LLM responses into reliable, schema-validated structured data by using Pydantic models, automatic retries on validation failures, and optional streaming of partial results.

Core Features & Use Cases

  • Pydantic-based response schemas: Define the exact output structure with types, constraints, nested models, optionals, and enums for safe parsing.
  • Automatic validation + retry: Detect invalid outputs and re-prompt with validation error feedback until the response conforms to your schema.
  • Streaming for real-time pipelines: Receive partial objects while generation is in progress, enabling incremental UI updates or progressive downstream processing.
  • Provider support with consistent behavior: Use Instructor with multiple LLM providers (e.g., Anthropic Claude and OpenAI) while keeping your extraction contract stable.

Use Instructor when you need to extract entities, generate classifications, normalize complex JSON, or build structured research artifacts from LLM output with robust failure recovery.

Quick Start

Use the instructor skill to extract user data from a prompt into a Pydantic schema and automatically retry until the output validates.

Frequently Asked Questions about instructor

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

FAQPage Schema
How do I extract structured data from LLM outputs with Pydantic validation?

To extract structured data from LLM outputs with Pydantic validation, define a response_model schema and use automatic retry logic to re-prompt the LLM until the output conforms to your types, constraints, and enums.

What is the best way to normalize messy LLM responses into JSON?

The best way to normalize messy LLM responses into JSON is using Pydantic-based response schemas with automatic validation and repair, which detects invalid outputs and re-prompts with validation error feedback until the response validates.

Can I use Instructor for structured data extraction with Anthropic Claude and OpenAI?

Yes, you can use Instructor for structured data extraction with Anthropic Claude and OpenAI, ensuring consistent extraction behavior and stable response contracts across multiple LLM provider APIs.

Does streaming partial structured data from LLMs work in real-time pipelines?

Yes, streaming partial structured data from LLMs works in real-time pipelines by receiving partial Pydantic objects while generation is in progress, enabling incremental UI updates or progressive downstream processing.

Why does my LLM JSON extraction fail schema validation and need automatic retry?

LLM JSON extraction fails schema validation when outputs do not conform to your Pydantic model types, requiring automatic retry logic that feeds validation error messages back to the LLM to repair the response.