Last active
July 13, 2024 13:42
-
-
Save paicha/d26e48a0288df22c3fad12eb9547ef94 to your computer and use it in GitHub Desktop.
Create an OpenAI API proxy using only 10 lines of code on Cloudflare Worker.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function handleRequest(request) { | |
const url = new URL(request.url) | |
url.host = "api.openai.com" | |
return fetch(url, { headers: request.headers, method: request.method, body: request.body }) | |
} | |
addEventListener("fetch", (event) => { | |
event.respondWith(handleRequest(event.request)) | |
}) |
非常感谢您的内容,设置成功了!举手提问:适用于 Claude 么?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1024赞