DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to turn free text into a validated Pydantic object with Instructor

Define a model like User with name and age and let Instructor fill it from natural language.

Short answer: Install with pip install instructor; then Define a Pydantic BaseModel with the fields you want; create a client with Instructor.from_provider("openai/gpt-4o-mini"). All steps.

  • Top pick
  • Software and DevOps
  • Beginner
  • 15 minutes
  • From the README
  • Claude Code
  • Codex
  • Cursor
  • Gemini CLI

cost. Each extraction is a paid LLM call unless you use a local model.

Who it is forA backend developer parsing names, dates or amounts out of messages.

The problemHand-written JSON schemas and parsing code break often.

The outcomeA typed, validated object instead of a raw string.

What you need first

  • Python with pip, uv or poetry
  • An API key for your provider, or a local Ollama install
  • Basic Pydantic knowledge

Steps

  1. Install with pip install instructor
  2. Define a Pydantic BaseModel with the fields you want
  3. Create a client with Instructor.from_provider("openai/gpt-4o-mini")
  4. Call client.chat.completions.create with response_model set to your model and print the result

Prompt for your agent

Using 567-labs/instructor, install `pip install instructor`, define a Pydantic model for <the fields I need>, and write a function that extracts it from a list of support emails with client.chat.completions.create and response_model.

Caveat. This card is written from the 567-labs/instructor README, not from a test run by Deduped. Before you start, make sure you have Python with pip, uv or poetry. Check the repo for newer instructions before you rely on these steps.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for 567-labs/instructor and "Turn free text into a validated Pydantic object"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer