Structured Outputs: Make AI Return Data Your CRM Can Use
Structured output makes a language model return JSON that matches a schema you define. For GTM teams, that's the difference between AI that fills CRM fields and AI that breaks routing.
Structured output makes a language model return data in a shape you define, usually JSON that matches a JSON Schema. For GTM teams, it's the difference between AI that fills CRM fields and AI that breaks routing. You design the schema from your CRM properties, the API enforces it and code checks the rest.
Most AI-in-the-CRM projects fail on a boring detail. The model writes "Software, probably B2B SaaS" into a dropdown that expects "Software." The write fails, or worse, a text field takes it and routing never matches. Multiply that by a thousand records and nobody trusts the field again.
This explainer covers what structured output is, how OpenAI and Claude enforce it, how to design a schema your CRM accepts, the money math on getting it wrong and what can still break.
Key takeaways
- Shape, not truth. Structured output guarantees field names and types, not that the facts are right.
- Use the schema feature, not a prompt. Asking for JSON in the prompt fails more often than an enforced schema.
- Build the schema from CRM properties. Enums match dropdown values, numbers stay numbers and every field maps to one property.
- Always allow "unknown." A forced guess is worse than an honest blank that goes to review.
- Check the stop reason. Refusals and token limits can still return output that breaks the schema.
What is structured output in an LLM?
Structured output is an API feature that makes a model return JSON matching a schema you supply. The schema says which fields exist, what type each one is and which values are allowed.
Without it, you ask nicely in the prompt and hope. With it, the model is constrained as it writes. Anthropic's structured outputs docs say the feature guarantees "schema-compliant responses through constrained decoding." That means valid JSON, the right field types and the required fields present.
There are three levels of control. Only the last one is safe for CRM writes.
| Approach | What you get | Safe for CRM writes? |
|---|---|---|
| Ask for JSON in the prompt | Usually JSON, sometimes prose or broken JSON | No |
| JSON mode | Valid JSON, but any shape | No |
| Structured outputs with a schema | JSON that matches your schema | Yes, with validation |
OpenAI is direct about the gap. Its structured outputs guide says JSON mode doesn't enforce a schema and "only Structured Outputs ensure schema adherence." It adds: "We recommend always using Structured Outputs instead of JSON mode when possible."
Why does free text break your CRM?
CRMs run on exact values. Lead routing, scoring, lists and reports all filter on a field equal to a value. Free text from a model breaks that in four ways.
- Near-miss values. "SaaS," "Software" and "B2B software" are three segments to a filter.
- Wrong types. "About 200 people" can't go in a number field.
- Extra words. "Fit: A (strong match because...)" fails a dropdown.
- Invented fields. The model adds a key your sync doesn't expect, and the job errors.
Each of these is a data normalization problem you created on purpose. Structured output stops them at the source.
How do OpenAI and Claude enforce it?
Both major APIs support enforced schemas. Here's how they compare, per their own docs.
| OpenAI | Anthropic Claude | |
|---|---|---|
| Feature names | Structured Outputs (json_schema response format), strict function calling |
JSON outputs (output_config.format) and strict tool use (strict: true) |
| Schema input | JSON Schema, Pydantic, Zod | JSON Schema, Pydantic via the SDK |
| Models | Newer models, starting with GPT-4o | All models, per the docs |
| Refusals | Detectable in the response | stop_reason of "refusal," which may not match the schema |
| Known limits | Supported subset of JSON Schema | Some constraints unsupported, 20 strict tools per request |
Two Claude details matter for GTM builds. The docs say enum capitalization "isn't guaranteed," so compare values case-insensitively. And additionalProperties must be false, so the model "can only return the keys you list."
If you give an agent tool use, strict mode applies the same idea to tool inputs. The CRM update tool can only be called with valid fields. The guide to AI agents for GTM shows where this fits in a full agent build.
How do you design a schema your CRM can use?
Start from the CRM, not the prompt. Every schema field should map to exactly one CRM property. Here are my rules.
- One field, one property. Name schema fields after the property's internal name. The free CRM field naming checker helps keep names clean.
- Enums for dropdowns. Copy the dropdown's internal option values into the enum. Labels can differ from values, so use the values.
- Numbers as numbers. Employee count is an integer, not "about 200."
- Know the stored format. HubSpot's property field types docs say percentages are stored as decimals, so 75% is stored as .75.
- Always include unknown. Add "unknown" to every enum and allow null where a fact may not exist.
- Carry a source. Key facts get a source URL field next to them.
- Add a review flag. A
needs_reviewboolean lets the model say when it isn't sure.
What does a good schema look like?
Here's a trimmed example for an account research step. It writes industry, size band and fit tier, with a source and a review flag.
{
"type": "object",
"additionalProperties": false,
"required": ["industry", "employee_band", "fit_tier", "evidence_url", "needs_review"],
"properties": {
"industry": {
"type": "string",
"enum": ["software", "fintech", "healthcare", "ecommerce", "services", "unknown"]
},
"employee_band": {
"type": "string",
"enum": ["1-10", "11-50", "51-200", "201-1000", "1000+", "unknown"]
},
"fit_tier": { "type": "string", "enum": ["A", "B", "C", "unknown"] },
"evidence_url": { "type": ["string", "null"] },
"needs_review": { "type": "boolean" }
}
}
Treat this schema as a data contract between the AI step and the CRM. If someone adds a dropdown option, the schema changes too. The guide to data contracts for GTM covers how to keep both in sync.
Worked example: what loose output costs a month
Here's an example with assumed rates. Say an enrichment automation sends 1,000 records a month through an AI step that fills industry, size and fit tier.


With a free-text prompt, say 14% of records come back in a shape the CRM can't use. That's 140 records a month to fix by hand. Switch to JSON mode and the JSON parses, but fields still drift. Say that drops to 60 records. With an enforced schema plus an "unknown" option, only the honest unknowns go to review. Say that's 15 records.
At an assumed 3 minutes per manual fix, 140 records is 7 hours a month. Fifteen records is 45 minutes. The bigger cost is hidden, though. Every bad value that slips through misroutes a lead or drops an account from a segment. Nobody sees those, so nobody fixes them.
What can still go wrong with structured output?
The schema fixes the shape. It doesn't fix everything else. Plan for these.
| Failure | What happens | Fix |
|---|---|---|
| Refusal | Claude returns a 200 with stop_reason "refusal," and output may not match the schema |
Check the stop reason before you write anything |
| Token limit | Output is cut off and may be incomplete | Check for max_tokens, raise the limit and retry |
| Enum casing | "Fintech" vs "fintech" | Compare case-insensitively and normalize before the write |
| Valid but wrong | A clean value that is false for this company | Require a source URL and spot-check samples |
| Schema drift | A new dropdown option isn't in the enum | Update the schema with every property change |
The "valid but wrong" row is the big one. Structured output doesn't stop hallucination. It just makes wrong answers look tidy. Keep a test set of 30 to 50 records with known right answers, and run it every time you change the prompt or schema. That's what evals are for.
Then validate in code before the CRM write. Check that the evidence URL is on the company's domain. Check that employee band agrees with any number you already have. CRM-side validation rules add a second net, though they don't cover every write path.
How does this fit into a GTM build?
Structured output is one step in a longer chain. Here's the pattern I use.
- A trigger starts the job, like a new account or a form fill.
- The model gets the record, the sources and a prompt for the task.
- The API enforces the schema.
- Code checks the stop reason, the casing and the business rules.
- Records with
needs_reviewor unknowns go to a queue. - Clean records write to the CRM, and the run is logged.
If APIs are new to you, API basics for GTM covers the calls. For the research step itself, see AI account research agents. And for keeping the fields clean after they land, the HubSpot data quality guide and the CRM data hygiene playbook cover the ongoing work.
What to do this week
Pick one AI step that writes to your CRM and harden it.
- List the CRM properties it writes, with their types and dropdown values.
- Write a schema with one field per property and an "unknown" in every enum.
- Switch the step from a prompt-only request to the API's schema feature.
- Add checks for the stop reason and enum casing before the write.
- Pull 30 records with known answers and run them as a test set.
Want this built across your stack? That's part of our GTM engineering service. GTM engineers can see how I work on the GTM engineers page, and the AI agents and MCP use cases show the bigger picture.
FAQ
What is structured output in an LLM?
Structured output is a feature that forces a language model to return data in a format you define, usually JSON that matches a JSON Schema. Instead of a paragraph, you get fields with set names and types. Both OpenAI and Anthropic offer it in their APIs, and it is the safest way to send AI results into a CRM.
What is the difference between JSON mode and structured outputs?
JSON mode makes the model return valid JSON, but it doesn't check that the JSON matches your schema. Fields can be missing or named differently. Structured outputs constrain the response to your schema, so field names and types are right. OpenAI recommends structured outputs over JSON mode whenever possible.
Does structured output stop hallucinations?
No. It guarantees the shape of the answer, not the truth of it. A model can return a perfectly valid industry value that is wrong for that company. To catch wrong facts, require a source URL for key fields, allow an unknown value, validate with code and test changes against a set of known answers.
How do I map AI output to HubSpot dropdown properties?
Make the schema field an enum whose values match the dropdown's option values exactly. Then the model can only return a value the property accepts. Add an unknown option so the model has an honest choice when it isn't sure, and send unknowns to a review queue instead of the CRM.
Can I use structured outputs in Zapier or n8n?
Yes, if the AI step lets you supply a JSON schema or call the model API directly. Where it only offers free text, add a parsing step and a validation step after it, and route anything that fails to review. Calling the API with a schema is more reliable than asking for JSON in the prompt.