instructor

Extract structured data from LLM responses into Pydantic models.

1|Updated Feb 21, 2026
One-click install
npx skills add https://github.com/tianhao909/AI-Research-SKILLs-cn --skill instructor-tianhao909
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: instructor
Source: https://github.com/tianhao909/AI-Research-SKILLs-cn/tree/main/16-prompt-engineering/instructor
Command: npx skills add https://github.com/tianhao909/AI-Research-SKILLs-cn --skill instructor-tianhao909

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill solves the challenge of reliably extracting structured data from Large Language Model (LLM) responses, ensuring type safety and data integrity.

Core Features & Use Cases

  • Structured Data Extraction: Extract data into Pydantic models, guaranteeing format and type.
  • Automatic Validation & Retries: Automatically validates LLM outputs against your schemas and retries on failure.
  • Streaming Outputs: Stream partial results for real-time processing.
  • Use Case: When building an AI agent that needs to extract specific user details (name, age, email) from a conversational response, Instructor ensures the output is a valid Python object, not just raw text.

Quick Start

Use the instructor skill to extract user information into a Pydantic model named User.

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 responses?

To extract structured data from LLM responses, you can use Pydantic models to validate the output, ensuring type safety and data integrity while automatically retrying on validation errors.

What is the best way to validate LM outputs against a schema?

Validating LLM outputs against a schema is best handled by mapping responses to Pydantic models, which guarantees format and type safety while triggering automatic retries upon validation failure.

Does this approach work with OpenAI and Anthropic models?

Yes, structured data extraction with Pydantic validation works with both OpenAI and Anthropic models, requiring these dependencies to parse generative text into reliable Python objects.

Can I stream partial structured results during LLM generation?

Streaming partial structured results is supported, enabling real-time processing of LLM outputs as they are generated and validated against your defined Pydantic schemas.

How do I handle validation errors when parsing LLM outputs?

Handling validation errors when parsing LLM outputs is managed automatically through retries, where the system validates the response against your Pydantic schema and attempts generation again upon failure.

Why should I use Pydantic for structured LLM outputs?

Using Pydantic for structured LLM outputs guarantees that extracted data conforms to defined formats and types, solving unreliability by converting raw conversational text into valid Python objects.