instructor

Convert LLM responses into Pydantic-validated JSON with automatic retries.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Instructor eliminates unreliable, loosely formatted LLM responses by enforcing structured outputs that are validated and automatically retried when extraction fails.

Core Features & Use Cases

  • Validated structured outputs with Pydantic: Define a schema once and have the model return data that matches your types and constraints.
  • Automatic retry on validation errors: When fields don’t parse or constraints fail, the extraction is re-attempted with error feedback.
  • Robust JSON handling with type safety: Parse complex/nested objects and constrained values (e.g., enums, numeric bounds) without fragile manual parsing.
  • Streaming partial results: Emit incremental structured updates so downstream systems can react in real time.

Use Instructor when you need to extract entities, classify items, or convert long-form text into consistent JSON records for pipelines (ETL, reporting, search indexing, or tool-parameter generation).

Quick Start

Ask your AI to extract the required fields from the text and return them as a Pydantic model, retrying automatically if any fields fail validation.

Frequently Asked Questions about instructor

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

FAQPage Schema
How do I get structured JSON output from LLM responses using Pydantic?

To get structured JSON output from LLM responses, you define a Pydantic response_model schema to validate the data. This process converts unstructured text into reliable typed records and automatically retries extraction when validation fails.

What is the best way to parse nested objects from unstructured text for ETL pipelines?

The best way to parse nested objects for ETL pipelines is applying schema-constrained extraction with automatic validation retries. This converts long-form text into consistent JSON records by enforcing type safety on complex or constrained values without fragile manual parsing.

Does LLM data extraction work with both OpenAI and Anthropic APIs?

Yes, structured data extraction works with both OpenAI and Anthropic APIs. The extraction process applies Pydantic schemas across common provider APIs to validate responses, ensuring that nested objects and constrained values parse correctly regardless of the specific LLM provider.

Can I stream partial structured outputs from an LLM in real time?

Yes, you can stream partial structured outputs from an LLM in real time. This mechanism emits incremental structured updates as they are parsed, allowing downstream systems to react immediately to validated data fragments instead of waiting for the full response.

Why does LLM JSON parsing fail on missing or out-of-bounds fields, and how is it fixed?

LLM JSON parsing fails when fields don't match defined types or constraints. This is fixed using automatic retry on validation errors, which re-attempts the extraction with error feedback to ensure the model returns data matching your Pydantic schema.