x-dr / chatgptProxyAPI

🔥 使用cloudflare 搭建免费的 OpenAI api代理 ,解决网络无法访问问题。支持流式输出
https://chatai.451024.xyz
MIT License
2.95k stars 678 forks source link

请问,访问https://xxxxxx.workers.dev/v1/chat/completions,报这个错误是为什么呢? #20

Closed ziyou2 closed 1 year ago

ziyou2 commented 1 year ago

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

x-dr commented 1 year ago

看不懂英语可以用翻译,响应已经说得很清楚了