请问,访问https://xxxxxx.workers.dev/v1/chat/completions,报这个错误是为什么呢?
ziyou2 opened this issue · 1 comments
{
"error": {
"message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.",
"type": "invalid_request_error",
"param": null,
"code": null
}
}
使用的是
export default {
async fetch(request, env) {
const url = new URL(request.url);
url.host = "api.openai.com";
// openai is already set all CORS heasders
return fetch(url, {
headers: request.headers,
method: request.method,
body: request.body,
redirect: 'follow'
});
}
}
这个代码部署在workers
看不懂英语可以用翻译,响应已经说得很清楚了