Most OpenAI clients do not support Azure OpenAI Service, but the application for Azure OpenAI Service is very simple, and it also provides free quotas. This script uses a free Cloudflare Worker as a proxy, allowing OpenAI-supported clients to directly use Azure OpenAI Service.
Building upon the original project, this project incorporates the Serverless Framework to achieve automated deployment and updates, eliminating the need for manual deployment and updates.
- Do I need my own server?
- This script runs on Cloudflare Worker, eliminating the need for a server and card binding, with a free daily quota of 100,000 requests.
- Do I need my own domain?
- Not necessary. Refer to: haibbo#3
- Implementing a printer mode:
- Azure OpenAI Service's responses are segmented.
- When returning to the client, this project separates the messages into individual segments, achieving a printer-like mode.
- Project supports Serverless deployment (based on Serverless Framework).
Proxying requests from OpenAI to Azure OpenAI Service through Serverless automated deployment steps:
- Register and log in to your Cloudflare account.
- Obtain the required CLOUDFLARE_AUTH_KEY (Global API Key), CLOUDFLARE_AUTH_EMAIL, CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_ZONE_ID.
- Click the
Fork
button to create a new Worker project. - In your newly created project, set the obtained environment variables in the secrets section (see figure below for how to set secrets).
- After saving, switch to the
Actions
tab, selectCloudflare Workers
, click theRun workflow
button, and wait for the deployment to complete. - Optionally, bind a custom domain by following these steps: In the Worker details page -> Trigger -> Custom Domains, add a custom domain for this Worker.
First obtain the resourceName
and deployment mapper
, and log in to the Azure portal:
Required environment variables:
CLOUDFLARE_AUTH_KEY
: Cloudflare's Global API KeyCLOUDFLARE_AUTH_EMAIL
: Cloudflare account emailCLOUDFLARE_ACCOUNT_ID
: Cloudflare account IDCLOUDFLARE_ZONE_ID
: Cloudflare account zone IDRESOURCE_NAME
: Azure OpenAI Service nameDEPLOY_NAME_GPT35
: Azure OpenAI Service GPT-3.5 deployment nameDEPLOY_NAME_GPT4
: Azure OpenAI Service GPT-4 deployment name
Take OpenCat as an example: fill in the custom API domain name with the domain name bound in step 6:
I have tried multiple clients. If you encounter problems with other clients, please feel free to create an issue.
In your forked repository, click the sync fork
button to synchronize with this repository.