Skip to content

claude-3-haiku-20240307 is not supported on this API. Please use the Messages API instead

0

Hi, I operate in the eu-west-1 region and I want to use the bedrock batch API. According to docs, the anthropic claude-3 model is supported in eu-west-1 region. When I use the code below, the batch job finishes successfully but the result file e.g result.jsonl.output is like following

{"modelInput":{"prompt":"\n\nHuman: Sample prompt 40\n\nAssistant:","max_tokens_to_sample":100},"error":{"errorCode":400,"errorMessage":"\"claude-3-haiku-20240307\" is not supported on this API. Please use the Messages API instead.","retriable":false},"recordId":"0000040XYZ"}

my code

_client.create_model_invocation_job(
                roleArn=<my-role>,
                modelId="anthropic.claude-3-sonnet-20240229-v1:0",
                jobName="job-name",
                inputDataConfig=inputDataConfig,
                outputDataConfig=outputDataConfig,
            )

the input I provide for this batch job is a .jsonlfile with hundred lines like following

{"recordId": "0000001XYZ", "modelInput": {"prompt": "\n\nHuman: Sample prompt 1\n\nAssistant:", "max_tokens_to_sample": 100}}
...

asked a year ago606 views

1 Answer
1

The error you're encountering suggests that you're trying to use the Claude 3 model with an API that doesn't support it. The Claude 3 models, including Claude 3 Sonnet, require the use of the Messages API rather than the older Text Completion API.

For batch inference with Claude 3 models, you need to adjust your input format to match the Messages API structure. Instead of using the "prompt" field, you should structure your input as a list of messages. Here's an example of how your input .jsonl file should look:

{"recordId": "0000001XYZ", "modelInput": {"anthropic_version": "bedrock-2023-05-31", "max_tokens": 100, "messages": [{"role": "user", "content": "Sample prompt 1"}]}}

Make sure to update all entries in your input file to follow this format. The "anthropic_version" field is required for Claude 3 models.

Additionally, ensure that you have the necessary permissions and have been granted access to use the Claude 3 model in your region. If you continue to face issues, you may need to check your IAM permissions, verify your model access in the AWS Bedrock console, or contact AWS support for further assistance.

Remember that the Bedrock batch inference feature might still be in preview, which could lead to some inconsistencies or limitations across different regions and models. If you encounter persistent issues, consider using the real-time inference API as an alternative until batch inference is fully supported for your specific use case.
Sources
Accessing Amazon Bedrock Claude-3-Haiku and Claude-3-Sonnet models via Lambda Functions | AWS re:Post
problem with anthropic claude haiku | AWS re:Post
Bedrock API invocation error - on demand throughput isn's supported | AWS re:Post

answered a year ago

EXPERT

reviewed a year 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.