-
Notifications
You must be signed in to change notification settings - Fork 1k
apigw-lambda-bedrock-js-sam: Update ModelId to Claude Sonnet 4.5 #2906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
apigw-lambda-bedrock-js-sam: Update ModelId to Claude Sonnet 4.5 #2906
Conversation
| }, | ||
| ], | ||
| max_tokens: 200 | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Update for using Messages API.
https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-anthropic-claude-messages-request-response.html
| contentType: "application/json", | ||
| accept: "application/json", | ||
| modelId: "anthropic.claude-v2", | ||
| modelId: "global.anthropic.claude-sonnet-4-5-20250929-v1:0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Update ModelId.
| const response = { | ||
| statusCode: 200, | ||
| body: JSON.stringify(stringifiedResponse), | ||
| body: stringifiedResponse, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: Removed JSON.stringify because response escaped like this.
"{\"model\":\"claude-sonnet-4-5-20250929\",\"id\":\"msg_bdrk_016r5f2XBbdEPKDiAD24SJGq\",\"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 all the mass in our Solar System, making it by far the most dominant object gravitationally.\\n\\n3. **Eight planets** orbit our Sun in elliptical paths: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune, ranging from rocky inner planets to gaseous outer giants.\\n\\n4. **Beyond Neptune** lies the Kuiper Belt, home to dwarf planets like Pluto and countless icy objects left over from the Solar System's formation.\\n\\n5. **Scientists estimate** there are billions of other solar systems (planetary systems) throughout our Milky Way galaxy alone, many potentially harboring Earth-like worlds.\"}],\"stop_reason\":\"end_turn\",\"stop_sequence\":null,\"usage\":{\"input_tokens\":16,\"cache_creation_input_tokens\":0,\"cache_read_input_tokens\":0,\"output_tokens\":195}}"
| ```bash | ||
| sam delete | ||
| ``` | ||
| 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
Issue #, if available:
N/A
Description of changes:
Hi😀 Thanks for the useful patterns!
I noticed that Claude v2 can no longer be used. When actually deployed, the following error occurs:
{ "errorType": "ValidationException", "errorMessage": "The provided model identifier is invalid.", "name": "ValidationException", "$fault": "client", "$metadata": { "httpStatusCode": 400, "requestId": "d7a6a2ac-602f-4a12-9b3e-5beec109b346", "attempts": 1, "totalRetryDelay": 0 }, "stack": [ "ValidationException: The provided model identifier is invalid.", " at de_ValidationExceptionRes (/opt/nodejs/node_modules/@aws-sdk/client-bedrock-runtime/dist-cjs/protocols/Aws_restJson1.js:299:23)", " at de_InvokeModelCommandError (/opt/nodejs/node_modules/@aws-sdk/client-bedrock-runtime/dist-cjs/protocols/Aws_restJson1.js:101:25)", " at process.processTicksAndRejections (node:internal/process/task_queues:105:5)", " at async /opt/nodejs/node_modules/@smithy/middleware-serde/dist-cjs/deserializerMiddleware.js:7:24", " at async /opt/nodejs/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:14:20", " at async /opt/nodejs/node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:27:46", " at async /opt/nodejs/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26", " at async BufferedInvokeProcessor.handler (file:///var/task/index.mjs:26:15)", " at async BufferedInvokeProcessor.processInvoke (file:///var/runtime/index.mjs:1092:22)", " at async _Runtime.processSingleConcurrent (file:///var/runtime/index.mjs:1178:7)" ] }Therefore, I updated the model to use Claude Sonnet 4.5 instead.
Check
Thank you😀
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.