Attempting to write a PHP script to invoke request to Nova Pro LLM using curl. I have used the exact same PHP curl authentication method for all the Bedrock models I have accessed, including Titan and Anthropic models.
However, I am having difficulty using this same method to access the Nova Pro model. Attached is the PHP script: https://s3.us-west-2.amazonaws.com/docs.scbbs.com/docs/test/testNova04_debug.php
It just sends "Hello" to the Nova Pro 1.0 LLM.
This script also generates debug info to let me know where the failure is. This is the output:
root@ASUSET2410-Ubuntu:/home/ron/workarea/openai/php/aws/llms# php testNova04_debug.php
cURL Verbose Output:
- Trying 54.190.217.123:443...
- TCP_NODELAY set
- Connected to bedrock-runtime.us-west-2.amazonaws.com (54.190.217.123) port 443 (#0)
- ALPN, offering h2
- ALPN, offering http/1.1
- successfully set certificate verify locations:
- CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
- SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
- ALPN, server accepted to use h2
- Server certificate:
- subject: CN=bedrock-runtime.us-west-2.amazonaws.com
- start date: Aug 21 00:00:00 2024 GMT
- expire date: Sep 20 23:59:59 2025 GMT
- subjectAltName: host "bedrock-runtime.us-west-2.amazonaws.com" matched cert's "bedrock-runtime.us-west-2.amazonaws.com"
- issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M02
- SSL certificate verify ok.
- Using HTTP2, server supports multi-use
- Connection state changed (HTTP/2 confirmed)
- Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
- Using Stream ID: 1 (easy handle 0x563d5e6adea0)
POST /model/arn:aws:bedrock:us-west-2:214280194226:inference-profile/us.amazon.nova-pro-v1:0/invoke HTTP/2
Host: bedrock-runtime.us-west-2.amazonaws.com
content-type: application/json
accept: application/json
x-amz-date: 20241204T061725Z
authorization: AWS4-HMAC-SHA256 Credential={credentials}/20241204/us-west-2/bedrock-runtime/aws4_request, SignedHeaders=host;x-amz-date, Signature={signature}
content-length: 143
-
We are completely uploaded and fine
-
Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200
< date: Wed, 04 Dec 2024 06:17:25 GMT
< content-type: application/json
< content-length: 90
< x-amzn-requestid: 950e3396-fecc-4747-a9ea-6a9fb2747b46
<
-
Connection #0 to host bedrock-runtime.us-west-2.amazonaws.com left intact
Response:
Array
(
[Output] => Array
(
[__type] => com.amazon.coral.service#UnknownOperationException
)
[Version] => 1.0
)
root@ASUSET2410-Ubuntu:/home/ron/workarea/openai/php/aws/llms#
Observations:
Connection Successful:
The connection to the bedrock-runtime.us-west-2.amazonaws.com endpoint is established successfully.
SSL/TLS handshake and HTTP/2 upgrade are working fine.
Request Details:
Method: POST
Endpoint: /model/arn:aws:bedrock:us-west-2:214280194226:inference-profile/us.amazon.nova-pro-v1:0/invoke
Headers:
content-type: application/json
accept: application/json
x-amz-date: 20241204T061725Z
authorization: AWS4-HMAC-SHA256 Credential=..., Signature=...
Payload: Correct JSON payload with content-length: 143.
Response:
HTTP Status Code: 200 OK (No network or authorization issue).
Content-Type: application/json
Content-Length: 90
Error: UnknownOperationException
Analysis:
The UnknownOperationException is not caused by network or authentication problems but by the Bedrock API not recognizing the operation being requested. This means:
The endpoint is valid, but something about the request does not match what the API expects.
The AWS Bedrock API is successfully invoked, but the API returns an error because:
The operation (POST /model/.../invoke) is not supported for this ARN.
There is an issue with the payload structure.
Headers required for this operation are missing or incorrectly formatted.
Likely Issues:
ARN Formatting: The ARN being used may be incompatible with the /invoke operation. For Bedrock, ensure:
The ARN refers to a valid inference profile.
The format arn:aws:bedrock:us-west-2:214280194226:inference-profile/us.amazon.nova-pro-v1:0 is correct.
Headers: Some additional headers might be required, as seen in the successful BedrockRuntimeClient request:
X-Amz-User-Agent: aws-sdk-php/3.283.10 ...
aws-sdk-invocation-id: A unique identifier for the request.
Operation Mismatch: If the API expects a different path or parameters (e.g., a different inference profile or model ARN), it would result in this error.
Could someone please assist?
Region: us-west-2
There was a page that was available just yesterday, that I can't find anymore, that displayed the ARN for each model. All of the Nova models displayed only the inference profile ARNs. I can't even find where you go to locate the model ARN in the new model listing here: https://us-west-2.console.aws.amazon.com/bedrock/home?region=us-west-2#/providers/amazon
There is no documentation on how to implement the Nova API using curl.
you can find more additional documentation on using Nova models here: https://docs.aws.amazon.com/nova/latest/userguide/getting-started-api.html