Skip to content

Instantly share code, notes, and snippets.

@paicha
Last active July 2, 2024 07:06
Show Gist options
  • Save paicha/d26e48a0288df22c3fad12eb9547ef94 to your computer and use it in GitHub Desktop.
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.
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))
})
@TanyuuKaribusa
Copy link

非常感谢您的内容,设置成功了!举手提问:适用于 Claude 么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment