{
"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
{ "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