instructor

Extract and validate LLM outputs into Pydantic models with retries.

Updated May 4, 2026
One-click install
npx skills add https://github.com/Plaidmustache/hermes-nulab --skill instructor-plaidmustache
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: instructor
Source: https://github.com/Plaidmustache/hermes-nulab/tree/main/optional-skills/mlops/instructor
Command: npx skills add https://github.com/Plaidmustache/hermes-nulab --skill instructor-plaidmustache

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Structured data extraction from LLM responses with automated validation using Pydantic, reducing errors and rework.

Core Features & Use Cases

  • Type-safe extraction: Define Pydantic models to validate and coerce LLM outputs into concrete data structures.
  • Automatic retries: Retry failed extractions with informative feedback to improve reliability.
  • Streaming results: Receive partial results in real-time for interactive applications and dashboards.
  • Provider-agnostic workflows: Works with Claude, OpenAI, and local providers through a consistent API.

Quick Start

Define a Pydantic model for the desired output and use Instructor to extract, validate, and stream results from an LLM response.

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 using Pydantic?

You extract structured data from LLM outputs by defining a Pydantic model that represents your desired schema, then passing it to a validation library that coerces and validates the LLM response into type-safe data structures automatically.

What's the best way to validate LLM responses and retry on validation failures?

Validating LLM responses and retrying on failures is handled by passing validation errors back to the LLM as informative feedback, allowing the model to correct its output automatically until the Pydantic schema validation succeeds.

Can I stream partial structured data from LLMs in real-time?

Yes, you can stream partial structured data from LLMs in real-time by processing incremental Pydantic model fragments as they arrive, enabling interactive applications and dashboards to update continuously without waiting for the full response.

Does structured data extraction work with both OpenAI and Anthropic Claude models?

Structured data extraction works with both OpenAI and Anthropic Claude providers through a consistent, provider-agnostic API, allowing you to switch between different LLM backends while maintaining the same Pydantic validation and streaming workflow.

Do I need to define a Pydantic model before extracting structured data from LLM responses?

Yes, you must define a Pydantic model to serve as the expected schema before extracting structured data, as the validation, coercion, retry logic, and streaming all depend on this model to ensure type-safe results from the LLM output.

Why does my LLM structured output extraction fail validation on complex schemas?

LLM structured output extraction fails validation on complex schemas when the model's response does not match the Pydantic type constraints, but automatic retries address this by sending validation error feedback back to the LLM to improve subsequent attempts.