Last active
July 29, 2024 08:32
-
-
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 hidden or 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)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
非常感谢您的内容,设置成功了!举手提问:适用于 Claude 么?