
Day 3 - Turn Unstructured Text into Structured JSON with Amazon Bedrock
Build a meeting-notes extraction application using Amazon Bedrock Structured Outputs.
Series: 30 Days of AI Engineering on AWS (17 articles)
- …
- 4Day 3 - Turn Unstructured Text into Structured JSON with Amazon Bedrock This article
Welcome to Day 3 of 30 Days of AI Engineering on AWS!
On Day 1, we made our first foundation model API call using Amazon Bedrock.
On Day 2, we explored prompt engineering and learned how to guide a model's responses.
Today, we're addressing another important challenge in AI application development:
How do we turn unstructured text into predictable, machine-readable data?
Imagine receiving meeting notes, customer emails, or business documents. You want an AI application to extract important information and pass it directly to another application.
Asking an LLM to return JSON is one approach, but a prompt alone doesn't guarantee that the response follows your expected structure.
Amazon Bedrock provides a feature called Structured Outputs to address this problem.
Let's build something practical.
1. What are we building?
We'll create a meeting-notes extraction application.
Imagine receiving the following notes:
Project Alpha planning meeting — 14 November 2026.
Participants: Maya, Arjun, Chen.
Decision: The internal beta will launch on20 November 2026.
Arjun will create 10 test accounts by16 November 2026.
Maya will draft the onboarding guide,but no deadline was agreed.
Chen asked whether notifications shouldbe enabled by default.
No decision was made on notifications.The team will revisit this next meeting.Our application should extract:
- Meeting title and date.
- Participants.
- Decisions.
- Action items.
- Task owners and deadlines.
- Unresolved questions.
Instead of returning an ordinary paragraph, we'll generate a structured JSON object.
2. What is Structured Output?
Structured Outputs is an Amazon Bedrock capability that constrains model responses to follow a JSON Schema that you define.
For example, you can specify that your application expects:
{ "meeting_title": "string", "meeting_date": "string or null", "participants": ["string"], "decisions": ["string"], "action_items": [ { "task": "string", "owner": "string or null", "due_date": "string or null" } ], "open_questions": ["string"]}The model is constrained to return output that follows the supported schema.
This is different from simply writing "Return valid JSON" in a prompt.
Amazon Bedrock supports structured outputs through two complementary mechanisms:
JSON Schema output format: Constrains the model's text response to a specified JSON schema.
Strict tool use: Enforces schema requirements on tool names and tool inputs.
For today's exercise, we'll focus on JSON Schema output format using the Converse API.
3. Choose a compatible foundation model
There is one important compatibility detail.
In Days 1 and 2, we used Amazon Nova Lite. However, its current Bedrock model card lists Structured Outputs as unsupported.
For this exercise, we'll switch to Anthropic Claude Haiku 4.5, which supports Structured Outputs through the Bedrock Runtime Converse API.
Our configuration:
Component | Configuration |
|---|---|
AWS service | Amazon Bedrock |
Model | Claude Haiku 4.5 |
Model ID | global.anthropic.claude-haiku-4-5-20251001-v1:0 |
Region | us-east-1 |
SDK | Boto3 |
API | Converse |
Feature | Structured Outputs |
The model is accessed through a Global Cross-Region Inference Profile. We'll discuss the regional implications later in the article.
4. Prepare your environment
We'll continue with Python and Boto3.
Install or upgrade the SDK:
pip install --upgrade boto3Reuse your Amazon Bedrock API key or AWS credentials from the previous exercises.
For the short-term API key approach used earlier:
Windows PowerShell
$env:AWS_BEARER_TOKEN_BEDROCK="YOUR_API_KEY"Linux/macOS
export AWS_BEARER_TOKEN_BEDROCK="YOUR_API_KEY"Remember that short-term API keys expire. Generate a new key if your previous one is no longer valid.
Your IAM identity must have permission to invoke the selected inference profile and its underlying model resources.
5. Define your JSON Schema
Before invoking the model, we need to define the structure of the expected response.
Create a file named:
meeting_extractor.py Start with these imports:
import jsonimport boto3
from botocore.config import Configfrom botocore.exceptions import ClientError, BotoCoreErrorDefine the AWS configuration:
REGION = "us-east-1"
MODEL_ID = ( "global.anthropic.claude-haiku-4-5-20251001-v1:0")
client = boto3.client( "bedrock-runtime", region_name=REGION, config=Config( connect_timeout=10, read_timeout=120 ))Now define the schema:
MEETING_SCHEMA = { "type": "object", "properties": { "meeting_title": { "type": "string" }, "meeting_date": { "type": ["string", "null"] }, "participants": { "type": "array", "items": { "type": "string" } }, "decisions": { "type": "array", "items": { "type": "string" } }, "action_items": { "type": "array", "items": { "type": "object", "properties": { "task": { "type": "string" }, "owner": { "type": ["string", "null"] }, "due_date": { "type": ["string", "null"] } }, "required": [ "task", "owner", "due_date" ], "additionalProperties": False } }, "open_questions": { "type": "array", "items": { "type": "string" } } }, "required": [ "meeting_title", "meeting_date", "participants", "decisions", "action_items", "open_questions" ], "additionalProperties": False}A few important details:
-
requiredidentifies the fields that must appear.
-
additionalProperties: Falseprevents additional, undefined object properties.
-
["string", "null"]allows a field to contain a string or an explicit null value.
- Nested objects, such as individual action items, must also define their own schema.
These details matter because Bedrock supports a subset of JSON Schema Draft 2020-12, not every possible JSON Schema feature.
6. Invoke Amazon Bedrock using Structured Outputs
Now let's send the meeting notes to Claude Haiku 4.5.
Add the following code:
MEETING_NOTES = """Project Alpha planning meeting — 14 November 2026.
Participants: Maya, Arjun, Chen.
Decision: The internal beta will launch on20 November 2026.
Arjun will create 10 test accounts by16 November 2026.
Maya will draft the onboarding guide,but no deadline was agreed.
Chen asked whether notifications shouldbe enabled by default.
No decision was made on notifications.The team will revisit this next meeting."""
def extract_meeting_data(notes):
response = client.converse( modelId=MODEL_ID,
messages=[ { "role": "user", "content": [ { "text": ( "Extract the meeting information " "from the following notes.\n\n" f"{notes}" ) } ] } ],
inferenceConfig={ "maxTokens": 800 },
outputConfig={ "textFormat": { "type": "json_schema", "structure": { "jsonSchema": { "name": "meeting_minutes", "description": ( "Extract meeting details, " "decisions and action items." ), "schema": json.dumps( MEETING_SCHEMA ) } } } } )
# Check whether the response was truncated if response.get("stopReason") == "max_tokens": raise RuntimeError( "Response reached the token limit. " "Increase maxTokens and retry." )
# Extract the model response content = response["output"]["message"]["content"]
text_blocks = [ block["text"] for block in content if "text" in block ]
if not text_blocks: raise RuntimeError("No text response received.")
# Convert JSON text into a Python dictionary result = json.loads("".join(text_blocks))
print("\n===== EXTRACTED MEETING DATA =====\n")
print( json.dumps( result, indent=2, ensure_ascii=False ) )
# Display token usage usage = response.get("usage", {})
print("\n===== TOKEN USAGE =====") print("Input:", usage.get("inputTokens")) print("Output:", usage.get("outputTokens")) print("Total:", usage.get("totalTokens"))
if __name__ == "__main__":
try: extract_meeting_data(MEETING_NOTES)
except ClientError as error: details = error.response.get("Error", {})
print("AWS Error:", details.get("Code")) print("Message:", details.get("Message"))
except (BotoCoreError, json.JSONDecodeError, RuntimeError) as error: print("Application Error:", error)Run the application:
python meeting_extractor.pyThe first request may take longer because Amazon Bedrock compiles a grammar for a new schema. Subsequent requests using the same schema can reuse its cached grammar.
7. Understand the result
The application should return a JSON object similar to this:
{ "meeting_title": "Project Alpha planning meeting", "meeting_date": "2026-11-14", "participants": [ "Maya", "Arjun", "Chen" ], "decisions": [ "The internal beta will launch on 20 November 2026." ], "action_items": [ { "task": "Create 10 test accounts", "owner": "Arjun", "due_date": "2026-11-16" }, { "task": "Draft the onboarding guide", "owner": "Maya", "due_date": null } ], "open_questions": [ "Should notifications be enabled by default?" ]}The exact wording may vary, but the response must follow the defined schema.
Notice how the application can now access individual fields rather than trying to extract information from a paragraph.
For example:
for item in result["action_items"]:
print("Task:", item["task"]) print("Owner:", item["owner"]) print("Deadline:", item["due_date"]) print()This makes it easier to integrate model output into databases, APIs, dashboards, and other application workflows.
8. Important engineering considerations
Structured output does not mean factual correctness.
Bedrock constrains the structure of the response. It does not prove that the extracted meeting date, decision, or action item is factually correct. Application-level checks and human review may still be necessary.
Understand JSON Schema limitations.
Bedrock supports a subset of JSON Schema Draft 2020-12. For example, recursive schemas, external
$ref references, and certain numeric and string constraints are unsupported.Every object must explicitly specify
additionalProperties: false .Watch the token limit.
If the response reaches
maxTokens before the complete JSON object is generated, the result may be incomplete. Set the limit high enough for the expected output.Account for initial schema compilation.
The first request using a new schema can take up to approximately 90 seconds. AWS recommends setting the client read timeout to at least 120 seconds. Compiled schemas are cached for 24 hours.
Understand regional inference.
This example uses a Global Cross-Region Inference Profile. Requests can be routed across supported AWS commercial Regions, so this is not a single-Region data-residency configuration.
An important regional limitation: AWS explicitly documents that Claude Haiku 4.5 structured outputs are not supported through the India geographic inference profile (
in.anthropic.claude-haiku-4-5-20251001-v1:0 ). Do not substitute that profile in this example and expect structured output to work.For production workloads involving sensitive information, select a model and inference profile that meet your data-residency requirements.
9. Your Day 3 challenge
Try extending the application:
- Add a
meeting_summaryfield to the schema.
- Extract estimated task priority (
LOW,MEDIUM, orHIGH) using an enum.
- Test the application with notes that have missing dates or unassigned tasks.
- Compare this implementation with the prompt-only JSON approach from an ordinary LLM request.
Observe how schema constraints change the reliability of the response structure.
Day 3 Complete!
Today, we moved from ordinary text generation to structured data extraction.
We learned how to define a JSON Schema, use Amazon Bedrock's
outputConfig.textFormat , invoke a compatible foundation model, and parse the resulting JSON in Python.This is an important building block for applications that connect LLMs with databases, APIs, business workflows, and eventually AI agents.
30 Days. 30 Tasks. Real AI Building.
See you on Day 4!
Official References
Series: 30 Days of AI Engineering on AWS (17 articles)
- …
- 4Day 3 - Turn Unstructured Text into Structured JSON with Amazon Bedrock This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article