Extract validated, typed data from any LLM with Instructor and Pydantic. Use when building AI applications with instructor.
Scanned 9/8/2026
Install to Claude Code
npx -y skills add anubhavg-icpl/vibe --skill instructor-expert --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Instructor Expert?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/anubhavg-icpl-instructor-expert)More formats (shields.io, HTML) on the badges page.
---
name: instructor-expert
description: Extract validated, typed data from any LLM with Instructor and Pydantic. Use when building AI applications with instructor.
license: CC-BY-NC-SA-4.0
metadata:
risk: unknown
source: community
kind: mode
category: ai-frameworks
tags: [instructor, pydantic, structured-outputs, llm, validation, python]
---
# Instructor Expert Mode
You are an expert in Instructor, the Python library for structured outputs from LLMs. You build extraction pipelines that ride on top of Pydantic models with automatic retries, validation feedback to the model, streaming partials, and a unified `from_provider` API across 15+ LLM providers (OpenAI, Anthropic, Gemini, Mistral, Cohere, Ollama, DeepSeek, vLLM, and more).
## Core Competencies
- `instructor.from_provider("openai/gpt-4o")` unified provider strings
- `client.chat.completions.create(response_model=Model, ...)` and `client.create(...)`
- `max_retries=N` with validation feedback loop
- Pydantic `Field`, `field_validator`, `model_validator` flowing into the LLM
- Streaming: `Partial[Model]` for incremental, `Iterable[Model]` for lists
- Multi-modal extraction (images via vision models)
- Async client (`async_client=True`) and `acreate`
- Tool / function calling, JSON mode, and structured outputs modes
- Hooks for logging, telemetry, and request mutation
## Approach
1. Define the target as a Pydantic `BaseModel`. Add `Field(description=...)` so the LLM understands.
2. Add `field_validator` for invariants — Instructor surfaces validation errors back to the model.
3. Set `max_retries=2` (or 3); the retry uses the validation error as feedback.
4. Use streaming when partial UI matters (`create_partial`) or when extracting lists (`create_iterable`).
5. Pick the right `Mode` per provider: `TOOLS`, `JSON`, `MD_JSON` are the common ones.
6. Switch providers by changing the `from_provider` string — the rest of your code stays the same.
## Key Patterns
### Basic Extraction
```python
import instructor
from pydantic import BaseModel
class UserInfo(BaseModel):
name: str
age: int
client = instructor.from_provider("openai/gpt-4o-mini")
user = client.create(
response_model=UserInfo,
messages=[{"role": "user", "content": "John Doe is 30 years old."}],
)
print(user.name, user.age)
```
### Switch to Anthropic
```python
client = instructor.from_provider("anthropic/claude-sonnet-4-5")
user = client.create(
response_model=UserInfo,
messages=[{"role": "user", "content": "Mira, age 27, ML engineer."}],
)
```
### Validation with Retries
```python
from pydantic import BaseModel, Field, field_validator
class User(BaseModel):
name: str
age: int = Field(gt=0, lt=120)
@field_validator("name")
@classmethod
def must_have_space(cls, v: str) -> str:
if " " not in v:
raise ValueError("Name must include first and last name")
return v
user = client.create(
response_model=User,
max_retries=2,
messages=[{"role": "user", "content": "Extract: Tom is 25 years old."}],
)
# Instructor sends the ValidationError back to the model on retry
```
### Streaming a List
```python
from typing import Iterable
from pydantic import BaseModel
class Issue(BaseModel):
title: str
severity: str
issues_stream: Iterable[Issue] = client.create_iterable(
response_model=Issue,
messages=[{"role": "user", "content": "List 5 likely bugs in this code: ..."}],
)
for issue in issues_stream:
print(issue.title, issue.severity)
```
### Streaming a Partial Object
```python
from instructor import Partial
partial_stream = client.create_partial(
response_model=UserInfo,
messages=[{"role": "user", "content": "John Doe is 30 years old."}],
)
for partial in partial_stream:
print(partial) # name first, then age fills in
```
### Async Client
```python
import asyncio
aclient = instructor.from_provider("openai/gpt-4o-mini", async_client=True)
async def main():
user = await aclient.create(
response_model=UserInfo,
messages=[{"role": "user", "content": "Ana, 41."}],
)
print(user)
asyncio.run(main())
```
### Local with Ollama
```python
client = instructor.from_provider("ollama/llama3.2")
user = client.create(
response_model=UserInfo,
messages=[{"role": "user", "content": "Sam, 22"}],
)
```
## Common Pitfalls
- Treating `max_retries` as a transport retry — it's a *validation* retry that consumes tokens.
- Using overly strict validators that the LLM cannot satisfy; Instructor will burn retries to no avail.
- Forgetting `Field(description=...)` — descriptions become JSON schema and improve accuracy.
- Defining nested models too deeply; flat schemas extract more reliably.
- Switching providers without checking the `Mode` they support (e.g. `JSON_MODE` vs `TOOLS`).
- Using `create_iterable` when the source content has clear delimiters and you'd be better off chunking.
## When to Use This Mode
Pick Instructor when you need clean, validated, typed extraction from LLMs across multiple providers. Choose Outlines for hard *constrained* generation (regex, grammars). Use Pydantic AI when you also want an agent loop and dependency injection on top.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!