{
 "schema_version": 1,
 "generated": "2026-10-31",
 "id": "567-labs-instructor--auto-retry-failed-llm-validations-with-instructor",
 "repo": "567-labs/instructor",
 "repo_url": "https://github.com/567-labs/instructor",
 "repo_slug": "567-labs-instructor",
 "title": "Retry automatically when the LLM output fails validation",
 "page_title": "How to retry automatically when the LLM output fails validation with Instructor",
 "summary": "Add Pydantic field validators and let Instructor resend the error to the model until the data is valid.",
 "who": "A developer whose pipeline breaks on the occasional malformed answer.",
 "problem": "Invalid LLM output means manual retries and error handling code.",
 "outcome": "Data that passes your validators, with retries handled for you.",
 "steps": [
  "Install with `pip install instructor`",
  "Add a field_validator to your Pydantic model, for example on age",
  "Call client.chat.completions.create with response_model as usual",
  "Failed validations are retried with the error message, per the Automatic retries section"
 ],
 "agent_prompt": "Using 567-labs/instructor, add Pydantic field_validator rules for <my business rules> to my model and show how Instructor's automatic retries handle an input that fails them the first time.",
 "agents": [
  "claude-code",
  "codex",
  "cursor",
  "gemini-cli"
 ],
 "difficulty": "Intermediate",
 "time": "20 minutes",
 "basis": "readme",
 "caveat": "For agents with observability and traces, the README itself points to PydanticAI.",
 "category": "Software and DevOps",
 "tags": [
  "Software and DevOps"
 ],
 "lang": "python",
 "requirements": [
  "Python with pip, uv or poetry",
  "An API key for your provider, or a local Ollama install",
  "Basic Pydantic knowledge"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [
  {
   "tag": "cost",
   "notice": "Each retry is another LLM call."
  }
 ],
 "best": false,
 "score": 0.8,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/567-labs-instructor/auto-retry-failed-llm-validations-with-instructor/",
 "md": "https://dedupedai.com/use-cases/567-labs-instructor/auto-retry-failed-llm-validations-with-instructor/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/567-labs-instructor--auto-retry-failed-llm-validations-with-instructor.json",
 "api_version": "v1"
}
