You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apigw-lambda-bedrock-js-sam/README.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Amazon API Gateway to AWS Lambda to Amazon Bedrock using AWS SDK for JS and SAM
2
2
3
-
This sample project deploys an Amazon API Gateway REST API with an AWS Lambda integration. The Lambda function is written in TypeScript, calls the Amazon Bedrock API for Anthropic Claude-v2 model and returns a response containing the generated content.
3
+
This sample project deploys an Amazon API Gateway REST API with an AWS Lambda integration. The Lambda function is written in TypeScript, calls the Amazon Bedrock API for Anthropic Claude Sonnet 4.5 model and returns a response containing the generated content.
4
4
5
5
Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/apigw-lambda-bedrock-js-sam
6
6
@@ -100,16 +100,16 @@ Amazon Bedrock users need to request access to models before they are available
100
100
101
101
## How it works
102
102
103
-
This SAM project uses Amazon Bedrock API for Anthropic Claude-v2 model to generate content based on given prompt. This is exposed through a serverless REST API. Please refer to the architecture diagram below:
103
+
This SAM project uses Amazon Bedrock API for Anthropic Claude Sonnet 4.5 model to generate content based on given prompt. This is exposed through a serverless REST API. Please refer to the architecture diagram below:
104
104

105
105
106
106
Here's a breakdown of the steps:
107
107
108
108
1. **Amazon API Gateway**: Receives the HTTP POST request containing the prompt.
109
109
110
-
2. **AWS Lambda**: Triggered by the API Gateway, this functionforwards the prompt to Amazon Bedrock API using boto3 bedrock-runtime API. It uses Anthropic Claude-v2 model and sets other required parameters to fixed values for simplicity.
110
+
2. **AWS Lambda**: Triggered by the API Gateway, this functionforwards the prompt to Amazon Bedrock API using boto3 bedrock-runtime API. It uses Anthropic Claude Sonnet 4.5 model and sets other required parameters to fixed values for simplicity.
111
111
112
-
3. **Amazon Bedrock**: Based on the given prompt, using Anthropic Claude-v2 model generates the content and returns the response to Lambda.
112
+
3. **Amazon Bedrock**: Based on the given prompt, using Anthropic Claude Sonnet 4.5 model generates the content and returns the response to Lambda.
113
113
114
114
4. **Response**: Lambda processes the Bedrock output and sends it back to the user via the API Gateway.
115
115
@@ -124,18 +124,17 @@ curl -d '{"prompt": "Please write 5 lines on Solar Systems"}' -H 'Content-Type:
124
124
The API returns a response with generated content. Such as (Your output may vary):
125
125
126
126
```
127
-
"{\"completion\":\" Here are a few key things about Amazon Web Services (AWS):\\n\\n- AWS is a cloud computing platform that provides services like compute power, storage, databases, analytics, etc on demand over the internet. It operates data centers around the world that customers can access.\\n\\n- Some of the most popular AWS services are EC2 (virtual servers), S3 (cloud storage), Lambda (serverless computing), CloudFront (content delivery network), Route 53 (DNS service), and many more. \\n\\n- AWS was first launched in 2006 and has grown to be the largest cloud provider in the world. Many big companies like Netflix, Airbnb, Expedia rely on AWS for their infrastructure.\\n\\n- Customers pay only for the services they use without any upfront costs. This makes AWS attractive for startups and companies that want flexibility and don't want to manage their own hardware.\\n\\n- AWS offers high availability, scalability, security and reliability at a fraction of the\",\"stop_reason\":\"max_tokens\",\"stop\":null}"
127
+
{"model":"claude-sonnet-4-5-20250929","id":"msg_bdrk_01S1Rn7gPy3cdRt9aFWf255a","type":"message","role":"assistant","content":[{"type":"text","text":"# Five Facts About Solar Systems\n\n1. **Our Solar System** formed approximately 4.6 billion years ago from a giant rotating cloud of gas and dust called the solar nebula.\n\n2. **The Sun** contains 99.8% of the Solar System's total mass and provides the gravitational force that keeps all planets in orbit.\n\n3. **Eight planets** orbit our Sun in elliptical paths, divided into rocky terrestrial planets (Mercury, Venus, Earth, Mars) and gas/ice giants (Jupiter, Saturn, Uranus, Neptune).\n\n4. **Beyond Neptune** lies the Kuiper Belt, home to dwarf planets like Pluto and countless icy bodies left over from the Solar System's formation.\n\n5. **Scientists estimate** there are billions of other solar systems in our Milky Way galaxy alone, many potentially harboring planets in habitable zones."}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":16,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":0},"output_tokens":192}}
128
128
```
129
129
130
-
131
130
## Cleanup
132
131
133
132
1. To delete the resources deployed to your AWS account via AWS SAM, run the following command:
134
133
135
134
```bash
136
135
sam delete
137
136
```
138
-
2. Delete the Lambda layer version using the `delete_lambda_layer.sh` script. You may have to give execution permission to the file. You will need to pass the Lambda layer name and the version in the inpout when requested:
137
+
2. Delete the Lambda layer version using the `delete_lambda_layer.sh` script. You may have to give execution permission to the file. You will need to pass the Lambda layer name and the version in the input when requested:
Copy file name to clipboardExpand all lines: apigw-lambda-bedrock-js-sam/example-pattern.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,8 @@
8
8
"headline": "How it works",
9
9
"text": [
10
10
"Amazon API Gateway receives the HTTP POST request containing a text which will is taken as a prompt.",
11
-
"AWS Lambda is triggered by the API Gateway, this function forwards the prompt to Amazon Bedrock API using AWS SDK for javascript bedrock-runtime API. It uses Anthropic Claude-v2 model and sets other required parameters to fixed values for simplicity.",
12
-
"Based on the given prompt, using Anthropic Claude-v2 model, Amazon Bedrock generates the content and returns the response to Lambda.",
11
+
"AWS Lambda is triggered by the API Gateway, this function forwards the prompt to Amazon Bedrock API using AWS SDK for javascript bedrock-runtime API. It uses Anthropic Claude Sonnet 4.5 model and sets other required parameters to fixed values for simplicity.",
12
+
"Based on the given prompt, using Anthropic Claude Sonnet 4.5 model, Amazon Bedrock generates the content and returns the response to Lambda.",
13
13
"Lambda processes the Bedrock output and sends it back to the user via the API Gateway."
0 commit comments