Files
567-labs--instructor/docs/learning/getting_started/installation.md
T
wehub-resource-sync 97e91a83f3
Ruff / Ruff (push) Has been cancelled
Test / Core Tests (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.10) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.11) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.12) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.13) (push) Has been cancelled
Test / Offline Coverage Tests (Python 3.9) (push) Has been cancelled
Test / Full Coverage (Python 3.11) (push) Has been cancelled
Test / Core Provider Tests (OpenAI) (push) Has been cancelled
Test / Core Provider Tests (Anthropic) (push) Has been cancelled
Test / Core Provider Tests (Google) (push) Has been cancelled
Test / Core Provider Tests (Other) (push) Has been cancelled
Test / Anthropic Tests (push) Has been cancelled
Test / Gemini Tests (push) Has been cancelled
Test / Google GenAI Tests (push) Has been cancelled
Test / Vertex AI Tests (push) Has been cancelled
Test / OpenAI Tests (push) Has been cancelled
Test / Writer Tests (push) Has been cancelled
Test / Auto Client Tests (push) Has been cancelled
ty / type-check (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:36:38 +08:00

3.6 KiB

title, description
title description
Installing Instructor for LLM Structured Outputs Complete installation guide for Instructor with support for OpenAI, Anthropic, Google, and 15+ LLM providers. Get started in minutes.

Instructor Installation Guide: Setup for LLM Structured Outputs

Learn how to install Instructor, the leading Python library for extracting structured data from LLMs like GPT-4, Claude, and Gemini. This comprehensive installation tutorial covers all major LLM providers and gets you ready for production use.

Quick Start: Install Instructor for LLM Development

Get started with structured LLM outputs in seconds. Install Instructor using pip:

pip install instructor

Instructor leverages Pydantic for type-safe LLM data extraction:

pip install pydantic

Pro Tip: Use uv for faster installation: uv pip install instructor

LLM Provider Installation Guide

Instructor supports 15+ LLM providers. Here's how to install and configure each:

OpenAI (GPT-4, GPT-3.5)

OpenAI is the default LLM provider for Instructor. Perfect for GPT-4 and GPT-3.5-turbo structured outputs:

pip install instructor

Configure your OpenAI API key for LLM access:

export OPENAI_API_KEY=your_openai_key

Anthropic Claude LLM Setup

Extract structured data from Claude 3 models (Opus, Sonnet, Haiku) with native tool support:

pip install "instructor[anthropic]"

Configure Claude API access:

export ANTHROPIC_API_KEY=your_anthropic_key

Google Gemini LLM Integration

Use Gemini Pro and Flash models for structured outputs with function calling:

pip install "instructor[google-genai]"

Set up Gemini API access:

export GOOGLE_API_KEY=your_google_key

Cohere

To use with Cohere's models:

pip install "instructor[cohere]"

Set up your Cohere API key:

export COHERE_API_KEY=your_cohere_key

Mistral

To use with Mistral AI's models:

pip install "instructor[mistralai]"

Set up your Mistral API key:

export MISTRAL_API_KEY=your_mistral_key

LiteLLM (Multiple Providers)

To use LiteLLM for accessing multiple providers:

pip install "instructor[litellm]"

Set up API keys for the providers you want to use.

Verify Your Instructor LLM Setup

Test your Instructor installation with this simple LLM structured output example:

import instructor
from pydantic import BaseModel
class Person(BaseModel):
    name: str
    age: int

client = instructor.from_provider("openai/gpt-5-nano")
person = client.create(
    model="gpt-5.4-mini",
    response_model=Person,
    messages=[
        {"role": "user", "content": "John Doe is 30 years old"}
    ]
)

print(f"Name: {person.name}, Age: {person.age}")

Next Steps in Your LLM Tutorial Journey

With Instructor installed, you're ready to build powerful LLM applications:

  1. Create Your First LLM Extraction - Build structured outputs with any LLM
  2. Master Response Models - Learn Pydantic models for LLM data validation
  3. Configure LLM Clients - Set up OpenAI, Anthropic, Google, and more

Common Installation Issues

  • Import Errors: Ensure you've installed the provider-specific extras (e.g., instructor[anthropic])
  • API Key Issues: Verify your environment variables are set correctly
  • Version Conflicts: Use pip install --upgrade instructor to get the latest version

Ready to extract structured data from LLMs? Continue to Your First Extraction