Skip to content

Latest commit

 

History

History
72 lines (50 loc) · 4.06 KB

README_en.md

File metadata and controls

72 lines (50 loc) · 4.06 KB

cf-openai-azure-proxy with ⚡ Severless

serverless

English | 中文

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.

Description:

  • 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?
  • 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).

Deployment (with Serverless)

Proxying requests from OpenAI to Azure OpenAI Service through Serverless automated deployment steps:

  1. Register and log in to your Cloudflare account.
  2. Obtain the required CLOUDFLARE_AUTH_KEY (Global API Key), CLOUDFLARE_AUTH_EMAIL, CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_ZONE_ID.
  3. Click the Fork button to create a new Worker project.
  4. In your newly created project, set the obtained environment variables in the secrets section (see figure below for how to set secrets).
  5. After saving, switch to the Actions tab, select Cloudflare Workers, click the Run workflow button, and wait for the deployment to complete.
  6. Optionally, bind a custom domain by following these steps: In the Worker details page -> Trigger -> Custom Domains, add a custom domain for this Worker.

Instructions

First obtain the resourceName and deployment mapper, and log in to the Azure portal:

env

  • Set up repository secrets:

    new repository secrets new secret

Required environment variables:

  • CLOUDFLARE_AUTH_KEY: Cloudflare's Global API Key
  • CLOUDFLARE_AUTH_EMAIL: Cloudflare account email
  • CLOUDFLARE_ACCOUNT_ID: Cloudflare account ID
  • CLOUDFLARE_ZONE_ID: Cloudflare account zone ID
  • RESOURCE_NAME: Azure OpenAI Service name
  • DEPLOY_NAME_GPT35: Azure OpenAI Service GPT-3.5 deployment name
  • DEPLOY_NAME_GPT4: Azure OpenAI Service GPT-4 deployment name

Client

Take OpenCat as an example: fill in the custom API domain name with the domain name bound in step 6:

opencat

I have tried multiple clients. If you encounter problems with other clients, please feel free to create an issue.

Update

In your forked repository, click the sync fork button to synchronize with this repository.