# AI Proxy Worker
**๐ŸŒ Language / ่ฏญ่จ€** [๐Ÿ‡บ๐Ÿ‡ธ English](./README.en.md) | [๐Ÿ‡จ๐Ÿ‡ณ ไธญๆ–‡](./README.md)
**Enterprise-grade AI API Security Proxy** - Enable your frontend applications to securely access AI services without exposing API keys, powered by Cloudflare's global edge network for millisecond response times. > ๐Ÿš€ A universal AI API proxy service based on Cloudflare Workers that allows your applications to securely call various AI APIs [![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/qinfuyao/AI-Proxy-Worker) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE) ## โœจ Why Choose AI Proxy Worker? - ๐Ÿ” **Security First**: API keys stored server-side only, never accessible to clients - โšก **Lightning Fast**: Built on Cloudflare's global edge network with millisecond response times - ๐Ÿค– **Multi-Model Support**: Currently supports DeepSeek API, architecture designed to support future expansion to more AI service providers - ๐ŸŒŠ **Streaming Support**: Full SSE streaming response support for real-time conversation experience - ๐Ÿ›ก๏ธ **Production Ready**: Comprehensive error handling, security protection, and monitoring logs - ๐Ÿ’ฐ **Zero Cost Start**: Cloudflare Workers free tier is sufficient for personal use ## ๐Ÿš€ 5-Minute Quick Start ### 1. One-Click Deploy ```bash # Install Wrangler CLI npm install -g wrangler # Clone project git clone https://github.com/qinfuyao/AI-Proxy-Worker.git cd ai-proxy-worker # Login and deploy wrangler login wrangler secret put DEEPSEEK_API_KEY # Enter your DeepSeek API key wrangler secret put PROXY_KEY # Set access key (optional but recommended) wrangler publish ``` ### 2. Test Immediately ```bash curl -X POST https://your-worker.workers.dev/chat \ -H "Authorization: Bearer YOUR_PROXY_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "deepseek-chat", "messages": [{"role": "user", "content": "Hello!"}] }' ``` ## ๐ŸŽฏ Supported AI Models | Model | Use Case | Features | |-------|----------|----------| | `deepseek-chat` | General conversation | DeepSeek-V3, 671B parameters, perfect for daily conversations | | `deepseek-reasoner` | Complex reasoning | DeepSeek-R1, expert in logical reasoning and math problems | ### ๐Ÿ”ฎ Roadmap **Current Version (v1.0)**: - โœ… Complete DeepSeek API support - โœ… Dual model support (conversation + reasoning) - โœ… Streaming response and comprehensive error handling **Planned Features**: - ๐Ÿ”„ OpenAI API support - ๐Ÿ”„ Claude API support - ๐Ÿ”„ Gemini API support - ๐Ÿ”„ Unified multi-AI routing - ๐Ÿ”„ User-level access control - ๐Ÿ”„ Request rate limiting and quota management ## โš™๏ธ Configuration Only two environment variables needed to get started: - `DEEPSEEK_API_KEY` - Your DeepSeek API key - `PROXY_KEY` - Custom access key (recommended) > ๐Ÿ“– **Complete Configuration Guide**: [Detailed Configuration](./docs/Configuration.en.md) ## ๐Ÿ“ฑ Client Integration Examples ### iOS (Swift) ```swift let response = try await URLSession.shared.data(for: URLRequest( url: URL(string: "https://your-worker.workers.dev/chat")!, headers: ["Authorization": "Bearer YOUR_PROXY_KEY"], body: ["model": "deepseek-chat", "messages": [...]] )) ``` ### JavaScript ```javascript const response = await fetch('https://your-worker.workers.dev/chat', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_PROXY_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ model: 'deepseek-chat', messages: [{ role: 'user', content: 'Hello!' }] }) }); ``` ## ๐Ÿ“– Complete Documentation ### ๐Ÿ“š Detailed Guides - **[Installation Guide](./docs/Installation.en.md)** - Windows/macOS detailed installation steps - **[Deployment Tutorial](./docs/Deployment.en.md)** - Local CLI vs Web deployment comparison - **[API Documentation](./docs/API-Reference.en.md)** - Complete API reference and examples - **[Configuration Guide](./docs/Configuration.en.md)** - Advanced configuration and optimization options ### ๐Ÿ”ง Operations Support - **[Troubleshooting](./docs/Troubleshooting.en.md)** - Common issues and solutions - **[Monitoring Guide](./docs/Monitoring.en.md)** - Log viewing and performance monitoring - **[Security Best Practices](./docs/Security.en.md)** - Production environment security configuration ### ๐Ÿ’ก Use Cases - **[Usage Examples](./docs/Examples.en.md)** - Integration examples in various programming languages - **[Best Practices](./docs/Best-Practices.en.md)** - Performance optimization and usage recommendations ## ๐ŸŒŸ Project Highlights ```javascript // ๐Ÿ” Security: Server-side key storage env.DEEPSEEK_API_KEY // Only stored in Cloudflare // โšก Performance: Global edge computing Cloudflare Workers // 180+ data centers // ๐Ÿ›ก๏ธ Reliability: Comprehensive error handling { "error": "timeout", "message": "Request timeout after 30s", "timestamp": "2025-01-01T00:00:00.000Z" } // ๐ŸŒŠ Streaming: Real-time response Accept: text/event-stream ``` ## ๐Ÿค Community & Support ### ๐Ÿ’ฌ Get Help - [๐Ÿ“‹ Issues](../../issues) - Report bugs or suggest features - [๐Ÿ’ก Discussions](../../discussions) - Community discussion and experience sharing ### ๐Ÿ”ง Contribute - [๐Ÿค Contributing Guide](./docs/Contributing.en.md) - How to participate in project development - [๐Ÿ“ Code Standards](./docs/Code-Style.en.md) - Code style and best practices - [๐Ÿงช Testing Guide](./docs/Testing.en.md) - How to write and run tests ### ๐Ÿ“Š Project Status - โœ… **Stable Version**: v1.0.0 - ๐Ÿ”„ **Active Maintenance**: Regular updates and bug fixes - ๐ŸŒ **Production Use**: Stable operation in multiple projects ## ๐Ÿ† Use Cases > "AI Proxy Worker allows our iOS app to securely integrate AI features without worrying about API key exposure. Simple deployment and excellent performance!" > > โ€” iOS Developer > "Switching from DeepSeek to other AI service providers only requires a few lines of code changes. This flexibility is amazing." > > โ€” Full-stack Engineer ## ๐Ÿ“„ License This project is licensed under the [MIT License](./LICENSE). ---
**๐ŸŒŸ If this project helps you, please give it a Star!** [โญ Star](../../stargazers) โ€ข [๐Ÿด Fork](../../fork) โ€ข [๐Ÿ“ข Share](https://twitter.com/intent/tweet?text=AI%20Proxy%20Worker%20-%20Universal%20AI%20API%20proxy%20service%20based%20on%20Cloudflare%20Workers&url=https://github.com/qinfuyao/AI-Proxy-Worker)