Automationscribe.com
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us
No Result
View All Result
Automation Scribe
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us
No Result
View All Result
Automationscribe.com
No Result
View All Result

Structured outputs for Anthropic Claude fashions on Amazon Bedrock

admin by admin
October 20, 2026
in Artificial Intelligence
0
Structured outputs for Anthropic Claude fashions on Amazon Bedrock
399
SHARES
2.3k
VIEWS
Share on FacebookShare on Twitter


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:

  1. Schema validation – Amazon Bedrock validates your JSON schema towards the supported JSON Schema Draft 2020-12 subset.
  2. Grammar compilation – For brand spanking new schemas, Amazon Bedrock compiles a grammar artifact (the primary request may take barely longer).
  3. Caching – Compiled grammars are cached for twenty-four hours, making subsequent requests quicker.
  4. 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

import boto3
import json

REGION = "us-east-1" # Select your most popular area
bedrock_runtime = boto3.consumer(service_name="bedrock-runtime", region_name=REGION)

# Outline the JSON schema for structured output
schema = {
    "kind": "object",
    "properties": {
        "title": {"kind": "string", "description": "Buyer title"},
        "e mail": {"kind": "string", "description": "Buyer e mail handle"},
        "plan_interest": {"kind": "string", "description": "Product plan of curiosity"},
        "demo_requested": {"kind": "boolean", "description": "Whether or not a demo was requested"}
    },
    "required": ["name", "email", "plan_interest", "demo_requested"],
    "additionalProperties": False
}

# Make a request with structured outputs through the InvokeModel API
# (reusing the schema outlined for the Converse instance)
response = bedrock_runtime.invoke_model(
    modelId="international.anthropic.claude-sonnet-5-5",
    physique=json.dumps({
        "anthropic_version": "bedrock-2023-05-31",
        "max_tokens": 512,
        "messages": [
            {"role": "user", "content": (
                "Paulo Santos (paulo@example.com) is interested in our Enterprise plan "
                "and wants to schedule a demo for next Tuesday at 2pm."
            )}
        ],
        "output_config": {"format": {"kind": "json_schema", "schema": schema}}
    })
)

physique = json.masses(response["body"].learn())

# Test the cease motive earlier than parsing
if physique["stop_reason"] == "end_turn":
    result_text = subsequent(b["text"] for b in physique["content"] if b["type"] == "textual content")
    print(json.dumps(json.masses(result_text), indent=2))
elif physique["stop_reason"] == "max_tokens":
    print("Response truncated: improve max_tokens and retry.")

JSON

{
    "title": "Paulo Santos",
    "e mail": "paulo@instance.com",
    "plan_interest": "Enterprise",
    "demo_requested": true
}

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:

Import json
from anthropic import AnthropicBedrockMantle

# Reusing the consumer created within the Messages API instance
consumer = AnthropicBedrockMantle(aws_region="us-east-1")

message = consumer.messages.create(
    mannequin="anthropic.claude-sonnet-5",
    max_tokens=512,
    messages=[{"role": "user", "content": "What's the weather like in San Francisco?"}],
    instruments=[
        {
            "name": "get_weather",
            "description": "Get the current weather for a specified location",
            "strict": True,
            "input_schema": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "The city and state, e.g., San Francisco, CA"
                    },
                    "unit": {
                        "type": "string",
                        "enum": ["celsius", "fahrenheit"],
                        "description": "Temperature unit"
                    }
                },
                "required": ["location", "unit"],
                "additionalProperties": False
            }
        }
    ]
)

#Instrument inputs conform to the schema
for block in message.content material:
    if block.kind == "tool_use":
        print(f"Instrument: {block.title}")
        print(f"Enter: {json.dumps(block.enter, indent=2)}")

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:

import boto3
import json

REGION = "us-east-1" # Select your most popular area
bedrock_runtime = boto3.consumer(service_name="bedrock-runtime", region_name=REGION)

# Classification schema: enums limit output to a hard and fast set of labels
schema = {
    "kind": "object",
    "properties": {
        "class": {
            "kind": "string",
            "enum": ["billing", "technical", "account", "sales", "other"],
            "description": "Main ticket class"
        },
        "precedence": {
            "kind": "string",
            "enum": ["low", "medium", "high", "urgent"],
            "description": "Urgency based mostly on enterprise affect"
        },
        "sentiment": {
            "kind": "string",
            "enum": ["positive", "neutral", "negative"],
            "description": "Buyer sentiment"
        },
        "escalate": {"kind": "boolean", "description": "Whether or not a human ought to evaluation instantly"},
        "motive": {"kind": "string", "description": "One-sentence justification for the classification"}
    },
    "required": ["category", "priority", "sentiment", "escalate", "reason"],
    "additionalProperties": False
}

ticket = (
    "Our manufacturing API calls have been failing with 500 errors since this morning. "
    "We're shedding orders each minute. That is the second outage this month!"
)

# Make a request with structured outputs through the InvokeModel API
response = bedrock_runtime.invoke_model(
    modelId="international.anthropic.claude-haiku-5-5",
    physique=json.dumps({
        "anthropic_version": "bedrock-2023-05-31",
        "max_tokens": 512,
        "system": "You're a help ticket classifier. Classify the ticket precisely.",
        "messages": [
            {"role": "user", "content": f"Classify this support ticket:nn{ticket}"}
        ],
        "output_config": {"format": {"kind": "json_schema", "schema": schema}}
    })
)

physique = json.masses(response["body"].learn())

# Test the cease motive earlier than parsing
if physique["stop_reason"] == "end_turn":
    result_text = subsequent(b["text"] for b in physique["content"] if b["type"] == "textual content")
    end result = json.masses(result_text)
    print(json.dumps(end result, indent=2))
    # Route the ticket based mostly on the guaranteed-valid labels
    if end result["escalate"]:
        print(f"Escalating to on-call: {end result['category']} / {end result['priority']}")
elif physique["stop_reason"] == "max_tokens":
    print("Response truncated: improve max_tokens and retry.")

Necessities and greatest practices

To make use of structured outputs successfully on Amazon Bedrock, comply with these tips:

  1. Set additionalProperties: false on all objects: That is required for structured outputs to work. With out it, your schema gained’t be accepted.
  2. Use descriptive discipline names and descriptions: Fashions use property names and descriptions to know what knowledge to extract. Clear names like customer_email outperform generic names like field1.
  3. Use enum for constrained values: When a discipline has a restricted set of legitimate values, use enum to constrain choices.
  4. 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.
  5. Reuse schemas to profit from caching: Construction your utility to reuse schemas throughout requests. The 24-hour grammar cache improves efficiency for repeated queries.
  6. 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_tokens is reached earlier than finishing). Deal with each instances in your code.
  7. 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

  1. All primary sorts: object, array, string, integer, quantity, boolean, null.
  2. enum (strings, numbers, booleans, or nulls solely).
  3. const, anyOf, allOf (with limitations).
  4. $ref, $def, and definitions (inner references solely).
  5. String codecs: date-time, time, date, period, e mail, hostname, uri, ipv4, ipv6, uuid.
  6. 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.

  1. Recursive schemas.
  2. Exterior $ref references.
  3. Numerical constraints (minimal, most, multipleOf).
  4. String constraints (minLength, maxLength).
  5. additionalProperties set 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

Anshika Saxena

Anshika Saxena

Anshika is a Generative AI Knowledge Scientist at AWS, targeted on Amazon Bedrock. She helps enterprise prospects speed up their generative AI and agentic AI adoption by guiding them via constructing and implementing options on Amazon Bedrock. She additionally works with ISVs and startups to allow them with the newest Anthropic providers on Amazon Bedrock.

Dani Mitchell

Dani Mitchell

Dani is a Senior Specialist Options Architect for Generative AI at AWS, engaged on go-to-market for Anthropic on Amazon Bedrock. He helps enterprises internationally design and deploy generative AI options utilizing Anthropic’s fashions and capabilities on Amazon Bedrock to construct scalable, production-ready functions.

Alfredo Castillo

Alfredo Castillo

Alfredo is a Senior Specialist Options Architect for Generative AI at AWS, specializing in Anthropic fashions go-to-market on Amazon Bedrock. He works with Monetary Providers prospects to design and scale generative AI options throughout distributed techniques and switch generative AI experiments into manufacturing workloads. Exterior of labor, he’s keen about household and endurance sports activities.

Aamna Najmi

Aamna Najmi

Aamna is a Senior Specialist Options Architect for Generative AI specializing in Anthropic fashions and operationalizing and governing generative AI techniques at scale on Amazon Bedrock. She helps ISVs remedy their challenges, embrace innovation, and create new enterprise alternatives with Amazon Bedrock.

Sofian Hamiti

Sofian Hamiti

Sofian is a know-how chief with over 12 years of expertise constructing AI options, and main high-performing groups to maximise buyer outcomes. He’s keen about empowering numerous skills to drive international affect and obtain their profession aspirations.

Ayan Ray

Ayan Ray

Ayan is a Principal Associate Options Architect and AI Tech Lead at AWS, serving because the Worldwide Tech Lead for Anthropic at AWS. He works on the intersection of cloud structure and Synthetic Intelligence, serving to organizations undertake and scale Anthropic’s applied sciences on AWS.

Tags: AmazonAnthropicBedrockClaudeModelsoutputsStructured
Previous Post

Amazon SageMaker JumpStart: 2026 year-to-date in overview

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Popular News

  • Greatest practices for Amazon SageMaker HyperPod activity governance

    Greatest practices for Amazon SageMaker HyperPod activity governance

    406 shares
    Share 162 Tweet 102
  • How Cursor Really Indexes Your Codebase

    405 shares
    Share 162 Tweet 101
  • Introducing the Amazon Bedrock AgentCore Code Interpreter

    405 shares
    Share 162 Tweet 101
  • Construct a serverless audio summarization resolution with Amazon Bedrock and Whisper

    404 shares
    Share 162 Tweet 101
  • Context Engineering — A Complete Fingers-On Tutorial with DSPy

    404 shares
    Share 162 Tweet 101

About Us

Automation Scribe is your go-to site for easy-to-understand Artificial Intelligence (AI) articles. Discover insights on AI tools, AI Scribe, and more. Stay updated with the latest advancements in AI technology. Dive into the world of automation with simplified explanations and informative content. Visit us today!

Category

  • AI Scribe
  • AI Tools
  • Artificial Intelligence

Recent Posts

  • Structured outputs for Anthropic Claude fashions on Amazon Bedrock
  • Amazon SageMaker JumpStart: 2026 year-to-date in overview
  • How Tamnoon constructed AI-powered cloud safety remediation with Amazon Bedrock
  • Home
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms & Conditions

© 2024 automationscribe.com. All rights reserved.

No Result
View All Result
  • Home
  • AI Scribe
  • AI Tools
  • Artificial Intelligence
  • Contact Us

© 2024 automationscribe.com. All rights reserved.