Comments (4)
Howdy @watany-dev, the example you provided here has quite a bit more than the example in our docs (combining some of the Workers AI stuff, which is great overall but makes it harder to eval what exactly is wrong).
If you just run the example present in our docs, does that one work? Or does it also error out on you?
from cloudflare-docs.
This issue was closed automatically because there has been no response from the original author. As it stands currently, we don't have enough information to take action. If you believe this issue was closed in error, a) apologies and b) open a new issue and reference this one in the body.
from cloudflare-docs.
Hello!
I can confirm that the sample in your docs also does not work. This is the code that I am using:
import { AwsClient } from 'aws4fetch'
export default {
async fetch(request, env, ctx) {
const requestData = {
inputText: "What does ethereal mean?"
};
const headers = {
'Content-Type': 'application/json'
};
// sign the original request
const stockUrl = new URL("https://bedrock-runtime.us-east-1.amazonaws.com/model/amazon.titan-embed-text-v1/invoke")
const awsClient = new AwsClient({
accessKeyId: accessKey,
secretAccessKey: secretKey,
region: region,
service: "bedrock"
});
const presignedRequest = await awsClient.sign(stockUrl.toString(), {
method: "POST",
headers: headers
});
console.log(presignedRequest);
// change the signed request's host to AI Gateway
const stockUrlSigned = new URL(presignedRequest.url);
stockUrlSigned.host = "gateway.ai.cloudflare.com"
stockUrlSigned.pathname = `/v1/${cfAccountId}/${gatewayName}/aws-bedrock/bedrock-runtime/${region}/model/amazon.titan-embed-text-v1/invoke`
// make request
const response = await fetch(stockUrlSigned, {
method: 'POST',
headers: presignedRequest.headers,
body: JSON.stringify(requestData)
})
if (response.ok && response.headers.get('content-type')?.includes('application/json')) {
const data = await response.json();
return new Response(JSON.stringify(response));
} else {
// Display the data in the console
const data = await response.text();
console.log(data);
return new Response("Invalid response", { status: 500 });
}
},
};
The data
response I get is always:
{"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."}
I can also confirm that it is not a problem with my credentials, and I can see the request reaching Cloudflare's AI Gateway in my dashboard. It dies on hitting the amazon endpoint. I think it has something to do with the presignedRequest
but I have no idea what. I've tried a few different models for which I have access and the results have been the same.
from cloudflare-docs.
Thanks for re-flagging @kittykatattack, re-opening and raising for our ENG team.
from cloudflare-docs.
Related Issues (20)
- I have been blocked HOT 1
- cloudflare 登录失败 HOT 1
- cloudflare stream video How to close conversion m3u8 Multi bit rate,Keep only the original bitrate of the video HOT 4
- Port issue in Terraform HOT 2
- Integrating Cloudflare to my wordpress website. HOT 1
- Ms HOT 1
- Need instructions for existing workers
- feat: Add hono-rate-limiter
- Broken API docs links
- _cfuvid cookie shows as Other with description "Description is currently not available" HOT 1
- Broken Header Links Found
- Website not launching HOT 1
- Unused Image Files Found
- WARP Local Network Exclusion "0 min" behavior HOT 1
- website does not working HOT 1
- Transform via URL background supported values appears incorrect
- Please add dns URI type documentation
- Finding out on what account the money is payed HOT 1
- Static HTML Deployment Guide Issue
- can't open my website, it appears " 頁面重新導向不正確 連線到 www.eherber.com 時發生錯誤。 有時候停用或拒絕接受 Cookie 會造成此問題。
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cloudflare-docs.