Reputation: 1
Instead of using SDK, I want to call bedrock service using http rest api call so that I can get response accordingly. For your reference, I am giving you curl and response.
Reference link for creating headers : https://github.com/aws-samples/sigv4-signing-examples/blob/main/no-sdk/java/AWSSignerPostExample.java
curl --location 'https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-3-haiku-20240307-v1:0/invoke' --header 'Accept: application/json' --header 'Content-Type: application/json' --header 'X-Amz-Content-Sha256: beaead3198f7da1e70d03ab969765e0821b24fc913697e929e726aeaebf0eba3' --header 'X-Amz-Date: 20250121T174151Z' --header 'Authorization: AWS4-HMAC-SHA256 Credential=AKIAYPSHYQLIQXUFHN/20250121/us-east-1/bedrock/aws4_request, SignedHeaders=accept;content-length;content-type;host;x-amz-content-sha256;x-amz-date;x-amzn-bedrock-save, Signature=a6525479881bf0fa91d430959c72a2cec570754c9114d28ba3729172a20d571d' --data '{"anthropic_version": "bedrock-2023-05-31","max_tokens": 512,"messages": [{"role": "user","content": [{"type": "text","text": "What is java"}]}]}'
Below is our Reponse :-
{"id":"msg_bdrk_01Eeqqs7AfQqfrpi9cSuJt1L","type":"message","role":"assistant","model":"claude-3-haiku-20240307","content":[{"type":"text","text":"Java is a high-level, object-oriented programming language developed by Sun Microsystems (now owned by Oracle) in the early 1990s. It is designed to be simple, portable, and secure, making it a popular choice for a wide range of applications.\n\nSome key features of Java include:\n\n1.Java is a popular choice for backend development, server-side programming, and enterprise-level applications."}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":10,"output_tokens":374}}
I want to call the api of amazon bedrock service with my access key and secret key of aws and with my request. You can refer hearders in given curl in problem details
{"anthropic_version": "bedrock-2023-05-31","max_tokens": 512,"messages": [{"role": "user","content": [{"type": "text","text": "What is java"}]}]}
Now this should return me the response which I mentioned in details of my problem, but in my case its return that 403 forbidden error that the calculated signature does not match with the signature provided.
Upvotes: 0
Views: 119