Skip to content

Instantly share code, notes, and snippets.

View MOHU9527's full-sized avatar

吉吉 MOHU9527

View GitHub Profile
@MOHU9527
MOHU9527 / openai-proxy.js
Created November 9, 2023 05:54 — forked from paicha/openai-proxy.js
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))
})