# 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
[](https://deploy.workers.cloudflare.com/?url=https://github.com/qinfuyao/AI-Proxy-Worker)
[](./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)