AI Proxy Worker

🌍 Language / 语言

🇺🇸 English | 🇨🇳 中文

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 License: MIT

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

# 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

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

📱 Client Integration Examples

iOS (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

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

🔧 Operations Support

💡 Use Cases

  • Usage Examples - Integration examples in various programming languages
  • Best Practices - Performance optimization and usage recommendations

🌟 Project Highlights

// 🔐 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

🔧 Contribute

📊 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.


🌟 If this project helps you, please give it a Star!

Star🍴 Fork📢 Share

Description
No description provided
Readme 275 KiB
Languages
JavaScript 100%