Skip to content

Conversation

@kakakakakku
Copy link
Contributor

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

$ curl -s -d '{"prompt": "Please write 5 lines on Solar Systems"}' -H 'Content-Type: application/json'  https://9zuktk5ty3.execute-api.ap-northeast-1.amazonaws.com/v1/bedrock_test       
{"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}}

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.

},
],
max_tokens: 200
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contentType: "application/json",
accept: "application/json",
modelId: "anthropic.claude-v2",
modelId: "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
Copy link
Contributor Author

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,
Copy link
Contributor Author

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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants