Skip to content

Issue with AWS Lambda Calling Bedrock – Works with Sonnet 3.5 but Fails with Haiku3/Nova

0

I am using AWS Lambda to call Bedrock models using the following code:

Send the message.

response = bedrock_client.converse( modelId=model_id, messages=messages, system=system_text, inferenceConfig={"maxTokens": 1000, "temperature": 0, "topP": 0.0} ) When using Sonnet 3.5, everything works as expected. However, when I switch to Haiku3 or any Nova models, I encounter the following Lambda error:

LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html This issue occurs consistently with Haiku3/Nova but not with Sonnet 3.5. (actually Haiku worked well few months before)

Questions: Is there any known issue with Haiku3/Nova models when invoked via AWS Lambda? Are there any specific inference settings required for these models? Could this be related to a Lambda runtime compatibility issue with certain Bedrock models?

Would appreciate any insights or suggestions on resolving this issue. Thanks!

asked 2 years ago357 views

2 Answers
1

Based on the information provided, it appears you're encountering an issue specific to certain Amazon Bedrock models (Haiku3 and Nova) when invoked through AWS Lambda, while Claude 3.5 Sonnet works without problems. This suggests a potential compatibility issue or a difference in how these models need to be invoked. Here are some insights and suggestions to help resolve the issue:

  1. API Compatibility: The error message you're receiving indicates that there might be a mismatch in the API being used. Newer Claude models, including Haiku and Sonnet, typically require the use of the Messages API rather than the older Text Completions API. Make sure you're using the correct API for each model.

  2. Model IDs and Versions: Verify that you're using the correct and most up-to-date model IDs for Haiku3 and Nova models. The model IDs should be in the format "anthropic.claude-3-haiku-20240307-v1:0" for Haiku, for example.

  3. Request Body Format: The request body for Claude 3 models should include the "anthropic_version" parameter set to "bedrock-2023-05-31". Ensure your request is formatted correctly for these models.

  4. Lambda Runtime and Dependencies: Check that your Lambda function is using an up-to-date runtime and that the boto3 and botocore libraries are the latest versions. Outdated versions may not support newer Bedrock models.

  5. Permissions: Confirm that your Lambda function has the necessary permissions to invoke the Bedrock models. You may need to update the IAM role associated with your Lambda function.

  6. Error Handling: Implement more extensive error handling and logging in your Lambda function to gather more detailed information about where the error is occurring.

To resolve the issue:

  1. Update your code to use the Messages API for Claude 3 models (Haiku and Sonnet).
  2. Ensure you're using the correct model IDs and API versions for each model.
  3. Update the boto3 and botocore libraries in your Lambda function to the latest versions.
  4. Review and update the permissions for your Lambda function if necessary.
  5. Implement more detailed logging to pinpoint the exact cause of the error.

If the issue persists after trying these steps, consider opening a support ticket with AWS for more specific assistance with the Haiku3 and Nova models integration with Lambda.
Sources
Accessing Amazon Bedrock Claude-3-Haiku and Claude-3-Sonnet models via Lambda Functions | AWS re:Post
Upgrade boto3 and botocore in AWS Lambda to access new AI models | AWS re:Post
Troubleshoot Lambda function runtime version errors | AWS re:Post

answered 2 years ago

EXPERT

reviewed 2 years ago

0

Thank you for your detailed insights and recommendations. I really appreciate your help!

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.