Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsMar 30, 2026·2 min de lecture

Instructor — Structured Outputs from LLMs

Get structured, validated outputs from LLMs using Pydantic models. Works with OpenAI, Anthropic, Google, Ollama, and more. Retry logic, streaming, partial responses. 12.6K+ stars.

Introduction

Instructor makes it easy to get structured, validated data from LLMs. Define a Pydantic model, and Instructor handles prompting, parsing, validation, and retries automatically. Works with OpenAI, Anthropic, Google, Ollama, LiteLLM, and any OpenAI-compatible API. Supports streaming, partial responses, and complex nested schemas. 12,600+ GitHub stars, MIT licensed.

Best for: Developers who need reliable structured data extraction from LLMs — not free-text Works with: OpenAI, Anthropic, Google, Ollama, LiteLLM, Mistral, Cohere


Key Features

Type-Safe Extraction

Define output schema with Pydantic, get validated objects back:

class Contact(BaseModel):
    name: str
    email: str
    company: Optional[str] = None

Automatic Retries

If the LLM returns invalid data, Instructor retries with the validation error as context:

client.chat.completions.create(
    response_model=Contact,
    max_retries=3,  # auto-retry on validation failure
    ...
)

Streaming & Partial Responses

Stream structured objects as they're generated — great for UIs.

Multi-Provider

One API across OpenAI, Anthropic, Google Gemini, Ollama, Mistral, and more.

Complex Schemas

Nested models, lists, enums, optional fields, custom validators — full Pydantic support.


FAQ

Q: What is Instructor? A: A Python library that gets structured, validated outputs from LLMs using Pydantic models. Handles prompting, parsing, validation, and retries. 12.6K+ stars.

Q: Does it work with Claude? A: Yes, Instructor supports Anthropic Claude, OpenAI, Google Gemini, Ollama, and many more providers.


🙏

Source et remerciements

Created by Jason Liu. Licensed under MIT. instructor-ai/instructor — 12,600+ GitHub stars

Discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires