# Create an OpenAPI Reverse Proxy Using Reflare
## Metadata
**Status**:: #x
**Zettel**:: #zettel/literature
**Created**:: [[2023-04-22]]
**Tags**:: #proxy #cloudflare-worker
## Create the Project
First create the project `openai-gate` using [reflare](https://github.com/xiaoyang-sde/reflare) as the template.
```shell
npm init cloudflare openai-gate https://github.com/xiaoyang-sde/reflare-template
cd openai-gate
```
## Edit the Project
Change the name to "openai-gate" in `wranger.toml` and `package.json`.
Open `src/index.ts` and replace `httpbin.org` with `api.openai.com`.
## Publish the Project
Use the script below to install dependencies, log into Cloudflare, and publish the project.
```shell
npm install
npx wrangler login
npx wrangler publish
```
The final command results in a proxy base address in the format of `https://openai-gate.CLOUDFLARE_USERNAME.workers.dev`.
## Use the Proxy
Use the domain in the proxy base address provided by cloudflare to replace `api.openai.com`.
For example, in the openai python command tool, set the environment variable `OPENAI_API_BASE` :
```bash
export OPENAI_API_BASE="https://openai-gate.CLOUDFLARE_USERNAME.workers.dev/v1"
openai api chat_completions.create -m gpt-3.5-turbo -g user Hello
```