Amazon Bedrock now helps structured outputs for all Anthropic Claude fashions, on each the bedrock-runtime and bedrock-mantle endpoints, the place the mannequin is accessible.
Whether or not you name Claude via Boto3 and the bedrock-runtime APIs or via the Messages API and the bedrock-mantle endpoint, now you can obtain schema-compliant JSON responses that conform to an outlined construction. You now not want customized parsing, retry logic, or post-processing.
Sensible functions
With structured outputs for Claude on Amazon Bedrock, you may automate dependable, schema-compliant duties throughout industries. Examples embody extracting each required discipline from monetary earnings reviews and compliance paperwork, parsing medical notes into Digital Well being Data (EHR), and enriching product catalogs with constant, validated outcomes. You may also analyze contracts for key phrases, events, and obligations, or energy clever help ticket routing the place intents, sentiments, and entities all the time match your utility’s knowledge mannequin.
What modifications with structured outputs on Amazon Bedrock
Structured outputs use constrained decoding to implement your JSON schema throughout token era, not after the very fact. The mannequin doesn’t produce tokens that may violate your schema. This modifications output formatting from probabilistic to deterministic.
Two complementary mechanisms are actually obtainable on each Amazon Bedrock endpoints:
| Function | Goal | Use case |
| JSON Schema output format | Management the mannequin’s response construction | Knowledge extraction, report era, API responses |
| Strict instrument use | Validate instrument parameters towards schemas | Agentic workflows, operate calling, multi-step automation |
What this implies for you
Every response is a sound JSON, so that you now not encounter JSON.parse() errors or parsing exceptions. Responses are additionally kind protected: discipline sorts are enforced, and required fields are all the time current. As a result of outputs all the time conform to your schema, you don’t want retries to deal with schema violations, making your integration extra dependable. Structured outputs additionally constrains responses to solely the fields your schema defines, which reduces output token rely and may decrease inference prices for high-volume workloads. These properties make structured outputs manufacturing prepared, so you may deploy at scale with out extra schema-validation code.
Supported fashions and availability
Structured outputs works with batch inference, so you may course of massive volumes of requests asynchronously whereas nonetheless receiving schema-compliant outputs. On the bedrock-runtime endpoint, it additionally works with cross-Area inference, so you should utilize it throughout AWS Areas with out extra setup. In case you want responses in actual time, you may stream structured responses as typed occasions.
The way it works
Once you make a request with a JSON schema, right here’s what occurs behind the scenes:
- Schema validation – Amazon Bedrock validates your JSON schema towards the supported JSON Schema Draft 2020-12 subset.
- Grammar compilation – For brand spanking new schemas, Amazon Bedrock compiles a grammar artifact (the primary request may take barely longer).
- Caching – Compiled grammars are cached for twenty-four hours, making subsequent requests quicker.
- Constrained era – The mannequin generates tokens that produce legitimate JSON matching your schema.
Efficiency concerns
For efficiency, the primary request with a brand new schema may take longer as a result of Amazon Bedrock compiles a grammar artifact earlier than era begins. After that preliminary compilation, subsequent requests utilizing the identical schema run with minimal overhead as a result of the compiled grammar is cached. This cache is scoped to your account and lasts for twenty-four hours from first entry. Altering the construction of your JSON schema invalidates the cache and triggers a recent compilation, whereas altering solely the title or description fields leaves the cached grammar intact.
Getting began: Structured outputs with the InvokeModel API (bedrock-runtime)
The InvokeModel API takes the Anthropic-native request physique, so the schema goes in output_config.format as a JSON object fairly than a JSON string. The next instance exhibits tips on how to extract the structured lead knowledge from a buyer e mail utilizing boto3 with an Anthropic Claude mannequin:
Python
JSON
The response conforms to your schema. No extra validation is required.
For extra API utilization examples, together with the Messages API, see the accompanying pattern pocket book.
Amazon Bedrock Mantle is designed for agentic functions with server-side instruments, background inference, and stateful conversations. With strict instrument use on the bedrock-mantle endpoint, now you can assure that instrument parameters match your enter schema precisely. The next instance exhibits tips on how to outline a instrument with strict schema enforcement:
Setting strict: true constrains the mannequin’s instrument enter to match your schema precisely. The placement discipline is all the time a string, and the unit discipline is all the time both celsius or fahrenheit. The mannequin can’t add fields outdoors your schema, so the instrument enter comprises solely what your schema specifies.
That is particularly worthwhile for agentic use instances on Amazon Bedrock Mantle, the place fashions orchestrate multi-step workflows with server-side instruments like net search and code interpreter.
Prime use instances for Claude structured outputs
Structured outputs cut back error-handling complexity probably the most in three widespread patterns:
- Knowledge extraction: Extract fields from invoices, contracts, e mail, and transcripts into JSON that all the time matches your schema, able to load into databases or buyer relationship administration (CRM) techniques.
- Dependable agent instrument calls: Validate instrument arguments towards their schemas at era time, so multi-step agent workflows run with out failures from malformed enter.
- Classification at scale: Classify tickets, leads, or content material by intent, precedence, and sentiment for routing, moderation, and analysis.
Claude Haiku 5.5 reliably handles fast and repetitive workloads similar to summaries, compactions, database queries, and classification requests. The next instance exhibits tips on how to classify and route incoming knowledge utilizing the Invoke API and Haiku 5.5:
Necessities and greatest practices
To make use of structured outputs successfully on Amazon Bedrock, comply with these tips:
- Set additionalProperties: false on all objects: That is required for structured outputs to work. With out it, your schema gained’t be accepted.
- Use descriptive discipline names and descriptions: Fashions use property names and descriptions to know what knowledge to extract. Clear names like
customer_emailoutperform generic names likefield1. - Use enum for constrained values: When a discipline has a restricted set of legitimate values, use
enumto constrain choices. - Begin primary, then add complexity: Start with the minimal required fields and add complexity incrementally. Fundamental schemas compile quicker, are simpler to debug, and hold your request payload lean as a result of the schema counts towards the Converse API payload measurement.
- Reuse schemas to profit from caching: Construction your utility to reuse schemas throughout requests. The 24-hour grammar cache improves efficiency for repeated queries.
- Test the cease motive in each response: Two situations can produce non-conforming responses: refusals (when the mannequin declines for security causes) and token limits (when
max_tokensis reached earlier than finishing). Deal with each instances in your code. - Check with practical knowledge earlier than deployment: Validate your schemas towards production-representative inputs. Edge instances in actual knowledge usually reveal schema design points.
For extra greatest practices and schema design suggestions, see Structured outputs within the Amazon Bedrock Person Information.
Supported JSON Schema options
- All primary sorts:
object,array,string,integer,quantity,boolean,null. enum(strings, numbers, booleans, or nulls solely).const,anyOf,allOf(with limitations).$ref,$def, anddefinitions(inner references solely).- String codecs:
date-time,time,date,period,e mail,hostname,uri,ipv4,ipv6,uuid. - Array
minItems(solely values 0 and 1).
Not supported
These key phrases are accepted by the API however will not be enforced throughout era. A request that features them returns a profitable response, and the mannequin can nonetheless return values that violate them. Validate these constraints in your utility fairly than counting on the schema to implement them.
- Recursive schemas.
- Exterior
$refreferences. - Numerical constraints (
minimal,most,multipleOf). - String constraints (
minLength,maxLength). additionalPropertiesset to something apart from false.
Conclusion
Structured outputs for Anthropic Claude fashions on Amazon Bedrock gives the reliability that manufacturing AI functions require. It’s obtainable now on each the bedrock-runtime and bedrock-mantle endpoints. By combining JSON Schema output format and strict instrument use, you may construct knowledge pipelines that want no extra validation. You may also create dependable agentic workflows and manufacturing AI functions with out customized parsing or retry logic.
Structured outputs for Claude on Amazon Bedrock is now usually obtainable. To be taught extra, see the Amazon Bedrock documentation and discover our pattern pocket book.
What workflows might validated, schema-compliant JSON enhance in your group? Share your suggestions and questions within the feedback.
In regards to the authors

