instructor

Extract structured fields from LLM responses with Pydantic schema validation.

1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/eddielueng/hermes-agent-zh --skill instructor-eddielueng
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: instructor
Source: https://github.com/eddielueng/hermes-agent-zh/tree/main/optional-skills/mlops/instructor
Command: npx skills add https://github.com/eddielueng/hermes-agent-zh --skill instructor-eddielueng

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve?

Instructor helps you turn messy LLM text output into reliable, typed JSON by validating against a Pydantic schema and retrying automatically when extraction fails.

Core Features & Use Cases

  • Pydantic-validated structured outputs: Enforce strict types, constraints, enums, and nested models so downstream systems can trust the result.
  • Automatic retry on validation errors: When the model produces invalid data, Instructor feeds the error back and re-attempts extraction.
  • Streaming structured results: Receive partial objects in real time for responsive UIs and incremental processing.
  • Multi-provider consistency: Use the same structured extraction pattern across OpenAI and Anthropic (and JSON-mode fallbacks).

Quick Start

Use the instructor skill to extract a User object with fields name, age, and email from the message "John Doe is 30 years old. His email is [email protected]" and return validated Pydantic output.

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 validate the output against a Pydantic schema and automatically retry extraction when validation fails. This enforces strict types and constraints to produce trustworthy data for downstream pipelines.

Does Instructor work with both OpenAI and Anthropic APIs for structured output?

Yes, Instructor supports multi-provider consistency for structured output across OpenAI and Anthropic APIs. It applies the same Pydantic-validated extraction pattern across both providers, utilizing JSON-mode fallbacks to ensure consistent results.

How do I handle validation errors when parsing complex JSON from LLMs?

To handle validation errors when parsing complex JSON from LLMs, the system automatically feeds the validation error back to the model and re-attempts extraction. This retry mechanism ensures invalid data is corrected without manual intervention.

Can I stream partial structured results while extracting data from an LLM?

Yes, you can stream partial structured results while extracting data from an LLM. This feature allows you to receive real-time updates of Pydantic objects, enabling responsive user interfaces and incremental processing of data.

What is the best way to parse multiple entities from text using Pydantic?

The best way to parse multiple entities from text using Pydantic is to define nested models with strict constraints and enums. The extraction process validates these schemas automatically and retries on failures to ensure accurate multi-entity parsing.

Do I need Pydantic models to use structured output extraction?

Yes, you need Pydantic model definitions to use structured output extraction. Defining these models with strict types, constraints, and nested structures is required to enforce validation and generate trustworthy JSON for downstream use.