openai-proxy
openai-proxy copied to clipboard
GPT-4 api distribution and management tool. 一分钟分发和管理 OpenAI GPT-4 API。
🕸 OpenAI-Proxy
Distribute GPT-4 API to your team within 1 min.
一分钟分发和管理 OpenAI GPT-4 API。
💾 How to deploy?
This service is built on Google Cloud Functions or AWS Lambda. You can deploy it to your own cloud provider. Here is the instruction for Google Cloud Functions.
Configure Google Cloud Functions
- Set up a Google Cloud project if you don't already have one: https://console.cloud.google.com/
- Enable the Cloud Functions API for your project: https://console.cloud.google.com/apis/library/cloudfunctions.googleapis.com
- Install Google Cloud SDK on your local machine: https://cloud.google.com/sdk/docs/install
- Authenticate your account by running
gcloud auth loginin the terminal.
Deploy the Service
-
Clone this repository.
git clone https://github.com/doem97/openai-proxy.git cd openai-proxy -
Deploy the service to Google Cloud Functions. Please first edit
./deploy.shand modify USER_ID and OPENAI_API_KEY, and thenbash ./deploy.shYou will got output in the terminal like this:
... url: https://ip-address-of-service.cloudfunctions.net/${USER_ID} ...Please copy-paste this url for later use:
export PROXY_URL="the_url_in_output"
⬆️ How to use API?
Just like regular calling OpenAI API, but you need to change the API addr as proxy addr, and change Authorization: UserName field.
I gave an example in request.sh. Like this:
curl ${PROXY_URL}/openai \
-H "Content-Type: application/json" \
-H "Authorization: UserName ${USER_ID}" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hello world!"}]
}'
📝 How to know usage for each user?
Open browser and navigate to ${PROXY_URL}/log. You will see the usage of corresponding user.
⛔️ WARNING!!! Although not explicitly mentioned in OpenAI term of usage, using this proxy to share/distribute your remaining quota to public would be considered violation to OpenAI rules, and will cause account limitation/ban. PLEASE DON'T TRY TO DO SO!!
✅ PLEASE only use this system to control the api access WITHIN your team.