Companies throughout industries face a standard problem: how you can effectively extract priceless data from huge quantities of unstructured information. Conventional approaches usually contain resource-intensive processes and rigid fashions. This put up introduces a game-changing resolution: Claude Device use in Amazon Bedrock which makes use of the facility of huge language fashions (LLMs) to carry out dynamic, adaptable entity recognition with out intensive setup or coaching.
On this put up, we stroll via:
- What Claude Device use (operate calling) is and the way it works
- Learn how to use Claude Device use to extract structured information utilizing pure language prompts
- Arrange a serverless pipeline with Amazon Bedrock, AWS Lambda, and Amazon Easy Storage Service (S3)
- Implement dynamic entity extraction for numerous doc sorts
- Deploy a production-ready resolution following AWS finest practices
What’s Claude Device use (operate calling)?
Claude Device use, also referred to as operate calling, is a robust functionality that enables us to enhance Claude’s talents by establishing and invoking exterior features or instruments. This characteristic allows us to offer Claude with a group of pre-established instruments that it may entry and make use of as wanted, enhancing its performance.
How Claude Device use works with Amazon Bedrock
Amazon Bedrock is a totally managed generative synthetic intelligence (AI) service that gives a spread of high-performing basis fashions (FMs) from trade leaders like Anthropic. Amazon Bedrock makes implementing Claude’s Device use remarkably simple:
- Customers outline a set of instruments, together with their names, enter schemas, and descriptions.
- A person immediate is supplied that will require using a number of instruments.
- Claude evaluates the immediate and determines if any instruments might be useful in addressing the person’s query or job.
- If relevant, Claude selects which instruments to make the most of and with what enter.
Answer overview
On this put up, we show how you can extract customized fields from driver’s licenses utilizing Claude Device use in Amazon Bedrock. This serverless resolution processes paperwork in real-time, extracting data like names, dates, and addresses with out conventional mannequin coaching.
Structure
Our customized entity recognition resolution makes use of a serverless structure to course of paperwork effectively and extract related data utilizing Amazon Bedrock’s Claude mannequin. This strategy minimizes the necessity for complicated infrastructure administration whereas offering scalable, on-demand processing capabilities.
The answer structure makes use of a number of AWS providers to create a seamless pipeline. Right here’s how the method works:
- Customers add paperwork into Amazon S3 for processing
- An S3 PUT occasion notification triggers an AWS Lambda operate
- Lambda processes the doc and sends it to Amazon Bedrock
- Amazon Bedrock invokes Anthropic Claude for entity extraction
- Outcomes are logged in Amazon CloudWatch for monitoring
The next diagram exhibits how these providers work collectively:
Structure elements
- Amazon S3: Shops enter paperwork
- AWS Lambda: Triggers on file add, sends prompts and information to Claude, shops outcomes
- Amazon Bedrock (Claude): Processes enter and extracts entities
- Amazon CloudWatch: Displays and logs workflow efficiency
Stipulations
Step-by-step implementation information:
This implementation information demonstrates how you can construct a serverless doc processing resolution utilizing Amazon Bedrock and associated AWS providers. By following these steps, you’ll be able to create a system that routinely extracts data from paperwork like driver’s licenses, avoiding guide information entry and lowering processing time. Whether or not you’re dealing with a couple of paperwork or 1000’s, this resolution can scale routinely to fulfill your wants whereas sustaining constant accuracy in information extraction.
- Setting Up Your Atmosphere (10 minutes)
- Create supply S3 bucket for the enter (for instance, driver-license-input).
- Configure IAM roles and permissions:
{
“Model”: “2012-10-17”,
“Assertion”: [
{
“Effect”: “Allow”,
“Action”: “bedrock:InvokeModel”,
“Resource”: “arn:aws:bedrock:*::foundation-model/*”, “arn:aws:bedrock:*:111122223333:inference-profile/*”
},
{
“Effect”: “Allow”,
“Action”: “s3:GetObject”,
“Resource”: “arn:aws:s3:::amzn-s3-demo-bucket/*”
}
]
}
- Creating the Lambda operate (half-hour)
This Lambda operate is triggered routinely when a brand new picture is uploaded to your S3 bucket. It reads the picture, encodes it in base64, and sends it to Claude 4.5 Sonnet by way of Amazon Bedrock utilizing the Device use API.The operate defines a single software referred to as extract_license_fields for demonstration functions. Nevertheless, you’ll be able to outline software names and schemas based mostly in your use case — for instance, extracting insurance coverage card information, ID badges, or enterprise types. Claude dynamically selects whether or not to name your software based mostly on immediate relevance and enter construction.
We’re utilizing “tool_choice”: “auto” to let Claude determine when to invoke the operate. In manufacturing use circumstances, it’s possible you’ll need to hardcode “tool_choice”: { “sort”: “software”, “title”: “your_tool_name” } for deterministic conduct.- Go to AWS Lambda console
- Select Create operate.
- Choose Creator from scratch.
- Set runtime to Python 3.12.
- Select Create Perform.
- Configure Lambda Timeout
- In your Lambda operate configuration, click on Normal Configuration tab.
- Beneath Normal Configuration, click on Edit
- For Timeout, enhance from default 3 seconds to a minimum of 30 seconds. We advocate setting it to 1-2 minutes for bigger photographs.
- Select Save.
Be aware:
This adjustment is essential as a result of processing photographs via Claude might take longer than Lambda’s default timeout, particularly for high-resolution photographs or when processing a number of fields. Monitor your operate’s execution time in CloudWatch Logs to fine-tune this setting on your particular use case.
- Paste this code within the lambda_function.py code file:
import boto3, json
import base64def lambda_handler(occasion, context):
bedrock = boto3.shopper(“bedrock-runtime”)
s3 = boto3.shopper(“s3”)bucket = occasion[“Records”][0][“s3”][“bucket”][“name”]
key = occasion[“Records”][0][“s3”][“object”][“key”]
file = s3.get_object(Bucket=bucket, Key=key)# Convert picture to base64
image_data = file[“Body”].learn()
base64_image = base64.b64encode(image_data).decode(‘utf-8’)# Outline software schema
instruments = [{
“name”: “extract_license_fields”,
“input_schema”: {
“type”: “object”,
“properties”: {
“first_name”: { “type”: “string” },
“last_name”: { “type”: “string” },
“issue_date”: { “type”: “string” },
“license_number”: { “type”: “string” },
“address”: {
“type”: “object”,
“properties”: {
“street”: { “type”: “string” },
“city”: { “type”: “string” },
“state”: { “type”: “string” },
“zip”: { “type”: “string” }
}
}
},
“required”: [“first_name”, “last_name”, “issue_date”, “license_number”, “address”]
}
}]payload = {
“anthropic_version”: “bedrock-2023-05-31”,
“max_tokens”: 2048,
“messages”: [{
“role”: “user”,
“content”: [
{
“type”: “image”,
“source”: {
“type”: “base64”,
“media_type”: “image/jpeg”,
“data”: base64_image
}
},
{
“type”: “text”,
“text”: “Extract the driver’s license fields from this image.”
}
]
}],
“instruments”: instruments
}strive:
response = bedrock.invoke_model(
modelId=”world.anthropic.claude-sonnet-4-5-20250929-v1:0″,
physique=json.dumps(payload)
)outcome = json.hundreds(response[“body”].learn())
# Print each step for debugging
print(“1. Uncooked Response:”, json.dumps(outcome, indent=2))if “content material” in outcome:
print(“2. Content material present in response”)
for content material in outcome[“content”]:
print(“3. Content material merchandise:”, json.dumps(content material, indent=2))if isinstance(content material, dict):
print(“4. Content material sort:”, content material.get(“sort”))if content material.get(“sort”) == “textual content”:
print(“5. Textual content content material:”, content material.get(“textual content”))if content material.get(“sort”) == “tool_calls”:
print(“6. Device calls discovered”)
extracted = json.hundreds(content material[“tool_calls”][0][“function”][“arguments”])
print(“7. Extracted information:”, json.dumps(extracted, indent=2))return {
“statusCode”: 200,
“physique”: json.dumps({
“message”: “Course of accomplished”,
“raw_response”: outcome
}, indent=2)
}besides Exception as e:
print(f”Error occurred: {str(e)}”)
return {
“statusCode”: 500,
“physique”: json.dumps({
“error”: str(e),
“sort”: str(sort(e))
})
} - Deploy the Lambda Perform: After pasting the code, select the Deploy button on the left aspect of the code editor and watch for the deployment affirmation message.
Vital: At all times bear in mind to deploy your code after making modifications. This ensures that your newest code is saved and will likely be executed when the Lambda operate is triggered.
- Go to AWS Lambda console
- Working with Claude Device use schemas
- Amazon Bedrock with Claude 4.5 Sonnet helps operate calling utilizing Device use — the place you outline callable instruments with clear JSON schemas. A sound software entry should embody:
- title: Identifier on your software (e.g. extract_license_fields)
- input_schema: JSON schema that defines required fields, sorts, and construction
- Instance Device use definition:
[{
“name”: “extract_license_fields”,
“input_schema”: {
“type”: “object”,
“properties”: {
“first_name”: { “type”: “string” },
“last_name”: { “type”: “string” },
“issue_date”: { “type”: “string” },
“license_number”: { “type”: “string” },
“address”: {
“type”: “object”,
“properties”: {
“street”: { “type”: “string” },
“city”: { “type”: “string” },
“state”: { “type”: “string” },
“zip”: { “type”: “string” }
}
}
},
“required”: [“first_name”, “last_name”, “issue_date”, “license_number”, “address”]
}
}] - You’ll be able to outline a number of instruments within the instruments array. Claude selects one (or none) relying on the tool_choice worth and the way nicely the immediate matches a given schema.
- Amazon Bedrock with Claude 4.5 Sonnet helps operate calling utilizing Device use — the place you outline callable instruments with clear JSON schemas. A sound software entry should embody:
- Configure S3 Occasion Notification (5 minutes)
- Open the Amazon S3 console.
- Choose your S3 bucket.
- Click on the Properties tab.
- Scroll right down to Occasion notifications.
- Click on Create occasion notification.
- Enter a reputation for the notification (e.g., “LambdaTrigger”).
- Beneath Occasion sorts, choose PUT.
- Beneath Vacation spot, choose Lambda operate.
- Select your Lambda operate from the dropdown.
- Click on Save modifications.
- Open the Amazon S3 console.
- Testing and Validation (quarter-hour)
- Supported Codecs: Claude 4.5 helps picture inputs in JPEG, PNG, WebP, and single-frame GIF codecs. Be aware: Whereas this implementation at the moment helps solely .jpeg photographs, you’ll be able to prolong assist for different codecs by modifying the media_type area within the Lambda operate to match the uploaded file’s MIME sort.
- Measurement and Decision Limits:
- Max picture dimension: 20 MB
- Really helpful decision: 300 DPI or increased
- Max dimensions: 4096 x 4096 pixels
- Photos bigger than this will likely fail to course of or produce inaccurate outcomes.
- Preprocessing Suggestions for Higher Accuracy:
- Crop the picture tightly to take away noise and irrelevant sections.
- Regulate distinction and brightness to make sure textual content is clearly legible.
- De-skew scans and guarantee textual content is horizontally aligned.
- Keep away from low-resolution screenshots or photographs with heavy compression artifacts.
- Want white backgrounds and darkish textual content for optimum OCR readability.
- Add Take a look at Picture:
- Open your S3 bucket
- Add a driver’s license picture (supported codecs: .jpeg, .jpg).
- Be aware: Guarantee picture is obvious and readable for finest outcomes.
- Monitor CloudWatch Logs
- Go to the Amazon CloudWatch console.
- Click on on Log teams within the left navigation.
- Seek for your Lambda operate title invoke_drivers_license.
- Click on on the newest log stream (sorted by timestamp).
- View the execution outcomes, which exhibits this pattern output:
{
“sort”: “tool_use”,
“id”: “toolu_bdrk_01Ar6UG7BcARjqAKsiSPyNdf”,
“title”: “extract_license_fields”,
“enter”: {
“first_name”: “JANE”,
“last_name”: “DOE”,
“issue_date”: “05/05/2025”,
“license_number”: “111222333”,
“handle”: {
“road”: “123 ANYWHERE STREET”,
“metropolis”: “EXAMPLE CITY”,
“state”: “VA”,
“zip”: “00000”
}
}
}
Efficiency optimization
- Configure Lambda reminiscence and timeout settings
- Implement batch processing for a number of paperwork
- Use S3 occasion notifications for computerized processing
- Add CloudWatch metrics for monitoring
Safety finest practices
- Implement encryption at relaxation for S3 buckets
- Use AWS Key Administration Service (KMS) keys for delicate information
- Apply least privilege IAM insurance policies
- Allow digital personal cloud (VPC) endpoints for personal community entry
Error dealing with and monitoring
- Claude’s output is structured as an inventory of content material blocks, which can embody textual content responses, tool_calls, or different information sorts. To debug:
- At all times log the uncooked response from Claude.
- Examine if tool_calls is current within the response.
- Use a try-except block across the operate name to catch errors like malformed payloads or mannequin timeouts.
- Right here’s a minimal error dealing with sample:
strive:
outcome = json.hundreds(response[“body”].learn())
if “tool_calls” in outcome.get(“content material”, [{}])[0]:
args = outcome[“content”][0][“tool_calls”][0][“function”][“arguments”]
print(“Extracted Fields:”, json.dumps(json.hundreds(args), indent=2))
besides Exception as e:
print(“Error occurred:”, str(e))
Clear Up
- Delete S3 bucket and contents.
- Take away Lambda features.
- Delete IAM roles and insurance policies.
- Disable Bedrock entry if now not wanted.
Conclusion
Claude Device use in Amazon Bedrock gives a robust resolution for customized entity extraction, minimizing the necessity for complicated machine studying (ML) fashions. This serverless structure allows scalable, cost-effective processing of paperwork with minimal setup and upkeep. By leveraging the facility of huge language fashions via Amazon Bedrock, organizations can unlock new ranges of effectivity, perception, and innovation in dealing with unstructured information.
Subsequent steps
We encourage you to discover this resolution additional by implementing the pattern code in your surroundings and customizing it on your particular use circumstances. Be a part of the dialogue about entity extraction options within the AWS re:Put up neighborhood, the place you’ll be able to share your experiences and be taught from different builders.
For deeper technical insights, discover our complete documentation on Amazon Bedrock, AWS Lambda, and Amazon S3. Think about enhancing your implementation by integrating with Amazon Textract for extra doc processing options or Amazon Comprehend for superior textual content evaluation. To remain up to date on related options, subscribe to our AWS Machine Studying Weblog and discover extra examples within the AWS Samples GitHub repository. When you’re new to AWS machine studying providers, try our AWS Machine Studying College or discover our AWS Options Library. For enterprise options and assist, attain out via your AWS account crew.
In regards to the authors
Kimo El Mehri
Kimo is an AWS Options Architect with experience spanning infrastructure, storage, safety, GenAI, and information analytics, amongst different areas. He’s keen about working with clients throughout numerous trade verticals, serving to them leverage AWS providers to drive their digital transformation and meet their enterprise wants.
Johana Herrera
Johana Herrera is a Options Architect at AWS, serving to firms modernize and develop within the cloud. She makes a speciality of generative AI and analytics, and loves serving to clients architect options with safety and resilience in thoughts. In her spare time, she enjoys spending time along with her two canines or watching sports activities.

