Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pokon548/ai-gateway-openai-wrapper
Provide OpenAI compatible, cost effective and proxied api endpoints on Cloudflare Worker. Foolproof considered
https://github.com/pokon548/ai-gateway-openai-wrapper
chatgpt cloudflare-workers openai-api
Last synced: 3 months ago
JSON representation
Provide OpenAI compatible, cost effective and proxied api endpoints on Cloudflare Worker. Foolproof considered
- Host: GitHub
- URL: https://github.com/pokon548/ai-gateway-openai-wrapper
- Owner: pokon548
- License: agpl-3.0
- Created: 2024-03-22T03:51:26.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-04-04T17:38:33.000Z (7 months ago)
- Last Synced: 2024-05-23T04:53:59.962Z (6 months ago)
- Topics: chatgpt, cloudflare-workers, openai-api
- Language: TypeScript
- Homepage:
- Size: 84 KB
- Stars: 123
- Watchers: 1
- Forks: 24
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AI Gateway (OpenAI) Wrapper
Provide you OpenAI compatible, cost effective and proxied api endpoints on Cloudflare Worker. Foolproof considered.[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/pokon548/ai-gateway-openai-wrapper)
## Features
- Expose [AI Gateway](https://developers.cloudflare.com/ai-gateway/) endpoint to OpenAI compatible APIs. Use proxied api anywhere.
- Foolproof design. You need to use dummy api key, which cannot be the same with your real OpenAI API key, to access proxied api. This helps you prevent leaking your real key and make sure you never send proxied requests to official endpoint.
- Cost effective. Use [Observe and control](https://developers.cloudflare.com/ai-gateway/get-started/configuring-settings/) to help you control expense and analyze api requests. Never receive surprise bills again!## Getting Started
1. Create your OpenAI API key on [OpenAI Platform](https://platform.openai.com/). For best foolproof effect, we recommend you do not reuse old one and create fresh new key *solely* used by this worker.
2. Create [AI Gateway](https://developers.cloudflare.com/ai-gateway/get-started/creating-gateway/) in Cloudflare.
3. Deploy this worker by [Clicking Here](https://deploy.workers.cloudflare.com/?url=https://github.com/pokon548/ai-gateway-openai-wrapper).
4. Add following environment variables to your newly created worker (Encrypting these variables is strongly advised!):
- `AI_GATEWAY_ENDPOINT_URL`: Your AI Gateway endpoint url. Should [looks like](https://developers.cloudflare.com/ai-gateway/get-started/connecting-applications/#openai): `https://gateway.ai.cloudflare.com/v1/ACCOUNT_TAG/GATEWAY/openai`.
- `DUMMY_WRAPPER_KEY`: Your API key supplied when you calling the wrapper endpoint. Can be any string. **This cannot be the the same with your real OpenAI key. Otherwise your request will be rejected by worker for foolproof reason**.
- `REAL_OPENAI_KEY`: Your real OpenAI API key. Should looks like: `sk-123456789012345678901234567890123456789012345678`.
5. Use your worker domain as endpoint and `DUMMY_WRAPPER_KEY` as api key. Profit.