Recommended Free Tools
To turn unstructured text into application data, define the target record as a Pydantic model, ask a compatible LLM API for a schema-constrained response, then validate the result and check its meaning in your own application. Structured output can enforce a response’s shape; it cannot prove that the extracted values are true or faithfully reflect the source.
How the conversion pipeline works
A reliable extraction workflow has four parts: describe the data your application needs, express that contract as a schema, obtain a structured response, and verify the result before using it. Treat the LLM as an extractor whose output still needs application-side checks—not as the authority on what the source document says.
As an Amazon Associate I earn from qualifying purchases.
- Define the target record. Choose fields, types, optional values, allowed choices, and constraints according to the downstream task.
- Generate or adapt a schema. Pydantic can produce JSON Schema, but the provider may support only a subset of its features.
- Request structured output. Use the selected provider’s native schema-constrained interface when it supports the required schema and model.
- Validate and assess meaning. Parse the response into the Pydantic model, then apply domain rules and compare important values with the source.
Define the record in Pydantic
Make the model reflect the record your software needs, rather than trying to capture every detail in the source. Use explicit types and optionality: a missing invoice number should be representable as missing, not guessed. Field descriptions can clarify what counts as a value and where it should come from.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
from pydantic import BaseModel, Field
class InvoiceFields(BaseModel):
supplier: str = Field(description="Supplier named on the invoice")
invoice_number: str | None = None
total: float | None = None
schema = InvoiceFields.model_json_schema()
This illustrates a Pydantic model and schema generation, not a complete provider request. Pydantic documents JSON Schema generation, including validation and serialization schema modes. Those modes can differ when a type’s accepted input and serialized representation are not the same, so choose the schema that matches what the model is expected to return.
#1 Best Overall
Use constraints and enums where they represent real application rules. A field description can explain extraction intent, but it is not a substitute for a machine-checkable constraint or a later domain check.
Choose the output method that fits the API
“JSON output” can mean different things. JSON mode aims to produce syntactically valid JSON; native structured output constrains responses to a supported schema. Function calling is generally for asking a model to invoke an application function or tool, whereas a response-format schema is suited to returning a schema-shaped object to the caller. These interfaces are not interchangeable, and exact availability depends on provider, model, and API surface.
Rank #2
| Approach | What it provides | What still needs attention |
|---|---|---|
| Native structured output | Schema adherence for supported schemas and supported model/API combinations. | Provider-specific schema limits, refusals or interrupted responses, application validation, and factual accuracy. |
| JSON mode | Valid JSON, according to OpenAI’s distinction between JSON mode and Structured Outputs. | It does not by itself ensure the object follows your particular schema; validate and handle errors. |
| Prompt-only formatting | Instructions asking the model to return a desired structure. | Adherence relies on the model following the prompt; parse, validate, and handle deviations. |
OpenAI’s Structured Outputs documentation describes Pydantic models as a way to define schemas through its Python library and distinguishes structured output from JSON mode. Pydantic AI describes native and prompted output, noting that prompted output is generally less reliable but may be necessary when native support is unavailable or appropriate for a particular quality need. Check the current documentation for the provider and model you plan to use; support and schema subsets vary.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Make the schema compatible with the provider
A schema emitted by Pydantic is not automatically accepted unchanged by every constrained-output API. Inspect the generated JSON Schema, compare its keywords and structure with the provider’s supported subset, and simplify or adapt it if needed. Keep the Pydantic model as the application’s validation contract even if the schema sent to the API must be a compatible adaptation.
Rank #3
- Confirm the feature is available for the exact model and API endpoint.
- Check which JSON Schema constructs are supported rather than assuming full compatibility.
- Choose validation or serialization schema mode based on the expected returned representation.
- Validate the actual response with Pydantic even when the provider constrains generation.
For OpenAI, consult the current Structured Outputs guide for implementation details and supported behavior. Pydantic’s version 2.12 JSON Schema reference explains its schema-generation options; neither source implies that every Pydantic feature is supported by every provider.
Validate structure, then verify the extracted facts
After receiving a response, first establish that the request completed successfully and did not produce a refusal or an incomplete result. Only then parse the returned object into the expected Pydantic model. A refusal or a response cut off by a token limit or other stopping condition may not conform to the requested schema; route these cases separately instead of treating them as ordinary extraction failures.
Rank #4
Successful parsing establishes that values fit the model’s types and constraints. It does not establish that the supplier, date, amount, or interpretation is correct. Add checks for domain meaning, cross-field relationships, required evidence, and ambiguous or absent source values. When auditability matters, consider recording source evidence—such as a supporting text span—alongside a value, then verify that evidence against the original document.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsOpenAI’s documentation warns that schema-constrained output can still contain mistakes in the values. See its Structured Outputs guide and refusal handling guidance. Pydantic’s validation checks are useful for enforcing the application contract, but semantic correctness requires separate checks.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Test extraction quality, not just parse success
Build a representative set of inputs and expected records before relying on the extraction in production. Include clean examples as well as incomplete, ambiguous, and difficult cases. Compare the extracted fields with the source and track semantic errors separately from schema or parsing failures. A response that parses successfully can still be wrong.
- Test missing values and make sure the model does not invent them.
- Check dates, amounts, names, and other high-impact fields against their source evidence.
- Exercise refusal, interrupted-generation, and validation-error paths.
- Measure field-level extraction quality as well as the rate of structurally valid responses.
Pydantic AI’s evaluation documentation describes evals and testing for agent behavior. The same principle applies to extraction: evaluate outputs against expected results, not only against the schema.
What published schema-following results do—and do not—show
In a 2024 announcement, OpenAI reported that gpt-4o-2024-08-06 achieved 100% on its evaluation of complex JSON Schema following, while gpt-4-0613 scored below 40% on that same evaluation. OpenAI also said the newer model scored 93% on the benchmark before deterministic constrained decoding was added. These are historical, vendor-reported schema-following results—not independent measures of general extraction accuracy or production success. The announcement is available at OpenAI’s 2024 Structured Outputs announcement.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteQuick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




