diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..b1f0f85963e747c0423ef3665d7144366ba9d8d4 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Helicone Proxy Service + +This project provides a proxy service designed to forward requests to either the Helicone API or the OpenAI API based on the request characteristics and the provided authorization tokens. + +## Usage + +To use this proxy replace `https://api.openai.com/v1` with `https://worker.hedenstroem.com/helicone-proxy/v1` when configuring the OpenAI Base URL. diff --git a/src/index.ts b/src/index.ts index b18da2aeb83c62f3a848284bf6921544c39354a8..2abb5d6fb3db813d1d6ab8ce4c51ab16f0767085 100644 --- a/src/index.ts +++ b/src/index.ts @@ -38,13 +38,12 @@ export default { // Add your custom header to the request modifiedRequest.headers.set("Host", url.hostname); - modifiedRequest.headers.set("Helicone-Auth", "Bearer " + env.HELICONE_KEY); - - // Make the fetch request with the modified request - const response = await fetch(modifiedRequest); + if (url.hostname === "oai.hconeai.com") { + modifiedRequest.headers.set("Helicone-Auth", "Bearer " + env.HELICONE_KEY); + } // Return the response from the target server - return response; + return fetch(modifiedRequest); }, };