Back to Discover

#json schema

1 prompt found

OpenAI Structured Outputs Schema Designer: JSON Schema Strict Mode, Refusal Paths, Pydantic Models, and Evaluation Fixtures
🤖 AI Tools

OpenAI Structured Outputs Schema Designer: JSON Schema Strict Mode, Refusal Paths, Pydantic Models, and Evaluation Fixtures

Ppromptstudio·Oct 8, 2026
No rating

Design an OpenAI Structured Outputs setup for a production extractor: a strict JSON Schema, matching Pydantic models, refusal and incompleteness paths, and a small fixture set so you can regression test parsing before you wire the schema into the API.

Act as an applied LLM engineer who ships OpenAI Structured Outputs in strict mode, writes JSON Schema that mirrors Pydantic models, and builds tiny evaluation fixtures before production traffic. Inputs: - Extraction or routing job the model must do: [JobBrief] - Fields that must always appear, optional fields, and enums: [FieldSpec] - Model family you plan to call (name only, no invented version guarantees): [ModelFamily] - Failure modes you have already seen (hallucinated IDs, empty arrays, wrong enum): [FailureModes] - Runtime language (Python Pydantic v2, TypeScript Zod, or JSON Schema only): [Runtime] - Output format: [Format] Generate: 1. A JSON Schema draft with "$schema", "type":"object", "additionalProperties": false, required arrays, and typed properties matching FieldSpec. 2. Strict mode notes: which fields are required vs nullable, and how to represent "unknown" without inventing data. 3. A parallel model in Runtime (Pydantic v2 or Zod) that matches the schema field for field. 4. Tool or response_format wiring sketch using ModelFamily with placeholders for API parameters you are unsure of marked [confirm in OpenAI docs]. 5. Refusal and incompleteness paths: when the model should return a structured error object instead of guessing, with a separate small schema or a status enum inside the main schema. 6. Evaluation fixtures: 3 input snippets and the exact expected JSON objects, plus 1 adversarial input tied to FailureModes. 7. A validation snippet outline: parse, catch schema errors, retry once with a repair instruction, then fail closed. 8. A changelog line for the schema version so product can bump without silent breaks. Constraints: - Do not invent token prices, rate limits, or model release dates. - Prefer enums over free text for categories the product already knows. - Honesty: at most one step that refuses to invent missing identifiers. - No em dashes.