Skip to content

aws_bedrock_runtime:invoke_model not working #161

@hedleym

Description

@hedleym

Hello:

When I make the following call (using version aws─1.0.7+build.995.refd16d091 on OTP27.2):

aws_bedrock_runtime:invoke_model(Client, ModelId, Body)

Where:

ModelId = ~"us.anthropic.claude-3-5-sonnet-20241022-v2:0"

and

Body = #{<<"anthropic_version">> => <<"bedrock-2023-05-31">>,
<<"max_tokens">> => 1024,
<<"messages">> =>
[#{<<"content">> =>
[#{<<"text">> => <<"Hello world">>,<<"type">> => <<"text">>}],
<<"role">> => <<"user">>}]}

AWS responds with:

{error,#{<<"message">> =>
<<"The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.">>},
{403,
[{<<"Date">>,<<"Mon, 20 Jan 2025 00:01:58 GMT">>},
{<<"Content-Type">>,<<"application/json">>},
{<<"Content-Length">>,<<"192">>},
{<<"Connection">>,<<"keep-alive">>},
{<<"x-amzn-RequestId">>,
<<"39c52d8a-a39c-42bb-a269-ec2735bdccc6">>},
{<<"x-amzn-ErrorType">>,
<<"InvalidSignatureException:http://internal.amazon.com/coral/com.amazon.coral.service/">>}],
#Ref<0.1110152351.2238447618.62956>}}

If I make the same request using the aws_cli, the query works (same credentials as above):

aws bedrock-runtime invoke-model --model-id "us.anthropic.claude-3
-5-sonnet-20241022-v2:0" --body "{"anthropic_version":"bedrock-2023-05-31","max_tokens":1024,"messages":[{"content":[{
"text":"Hello world","type":"text"}],"role":"user"}]}" output.txt
{
"contentType": "application/json"
}

file output.txt:

{"id":"msg_bdrk_013V7VAwj1mQxWZkqWWVK6pe","type":"message","role":"assistant","model":"claude-3-5-sonnet-20241022","content":[{"type":"text","text":"Hi! How are you today? I'm Claude, an AI assistant created by Anthropic. I aim to be direct and helpful while staying truthful about what I am. How can I help you?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":9,"output_tokens":45}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions