A comprehensive AI-powered platform built on Cloudflare Workers, featuring multi-modal capabilities, RAG (Retrieval Augmented Generation), content generation, and enterprise-grade security.
- Multi-Modal AI: Text generation, image creation, speech synthesis, and transcription
- RAG Implementation: Knowledge base with vector search for contextual responses
- Enterprise Security: Rate limiting, authentication, and compliance features
- Real-time Streaming: WebSocket support for real-time AI interactions
- Scalable Architecture: Built on Cloudflare's global network
- Comprehensive Monitoring: Analytics, performance metrics, and error tracking
- Node.js 18+
- Wrangler CLI (
npm install -g wrangler) - Cloudflare account with Workers AI enabled
-
Clone and setup:
git clone <repository-url> cd empathy-agency-ai-platform npm install
-
Configure environment:
cp .env.example .env # Edit .env with your configuration -
Deploy infrastructure:
chmod +x deploy.sh ./deploy.sh
-
Create API Token in Cloudflare Dashboard:
- Go to Profile β API Tokens β Create Token
- Select "Create Custom Token"
- Enable permissions: Workers, AI, D1, R2, KV, Queues
-
Set environment variables:
export CLOUDFLARE_API_TOKEN="your_api_token_here" export CLOUDFLARE_ACCOUNT_ID="5f837f5b7ca9c06d0053bacdd2d32370"
All API requests require Bearer token authentication:
curl -H "Authorization: Bearer your_jwt_token" \
https://api.empathyfirstmedia.com/api/ai/chatReal-time conversational AI with streaming support.
Request:
{
"messages": [
{"role": "user", "content": "Hello, how can you help me?"}
],
"model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast",
"stream": true,
"temperature": 0.7
}Response:
{
"response": "Hello! I can help you with content creation, research, analysis, and various AI-powered tasks...",
"requestId": "req_12345",
"usage": {"estimatedTokens": 25}
}Content generation with multiple output formats.
Request:
{
"prompt": "Write a blog post about AI in marketing",
"type": "article",
"length": "medium",
"style": "professional",
"model": "@cf/meta/llama-3.3-70b-instruct-fp8-fast"
}Knowledge base queries with retrieval augmentation.
Request:
{
"query": "What are the best practices for AI content generation?",
"topK": 5
}Health check endpoint.
βββββββββββββββββββ βββββββββββββββββββ
β Client Apps ββββββ Cloudflare β
β β β Workers β
βββββββββββββββββββ βββββββββββββββββββ
β
βββββββββββΌββββββββββ
β β β
βββββββββΌββββ βββββΌββββ βββββΌββββ
β Workers AI β β D1 β β R2 β
β Models β βDatabaseβ βStorageβ
βββββββββββββ βββββββββ βββββββββ
β β β
βββββββββΌββββ βββββΌββββ βββββΌββββ
β Vectorize β β KV β βQueues β
β Index β β Cache β βAsync β
βββββββββββββ βββββββββ βββββββββ
- API Requests: 100 per minute per user
- Token Usage: 10,000 tokens per hour per user
- Content Generation: 20 requests per minute
- JWT-based authentication
- API token validation
- Client identification and tracking
- End-to-end encryption
- GDPR compliance
- Data retention policies
- Audit logging
- Response times and latency
- Token usage and costs
- Error rates and types
- User engagement metrics
- Core Web Vitals tracking
- API performance metrics
- Error boundary reporting
- Client-side analytics
npm run devnpm test
npm run test:watchnpm run lint
npm run format
npm run typechecknpm run db:migrate
npm run db:seed./deploy.shwrangler deploywrangler secret put CLOUDFLARE_API_TOKEN
wrangler secret put DATABASE_URL- KV Cache: Frequently accessed data (24h TTL)
- R2 Storage: Generated content (1 year TTL)
- D1 Queries: Optimized with indexes
- Fast Responses:
@cf/meta/llama-3.1-8b-instruct-awq - High Quality:
@cf/meta/llama-3.3-70b-instruct-fp8-fast - Creative Tasks:
@cf/black-forest-labs/flux-1-schnell - Code Generation:
@cf/deepseek-ai/deepseek-r1-distill-qwen-32b
CLOUDFLARE_API_TOKEN=your_api_token
CLOUDFLARE_ACCOUNT_ID=your_account_id
ENVIRONMENT=production
AI_GATEWAY_ENABLED=true
RATE_LIMIT_REQUESTS_PER_MINUTE=100
RATE_LIMIT_TOKENS_PER_HOUR=10000See wrangler.toml for complete configuration including:
- Worker bindings
- Rate limiting rules
- Environment variables
- Queue consumers
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
- TypeScript for all code
- Comprehensive error handling
- Security-first approach
- Performance optimization
- Extensive logging and monitoring
MIT License - see LICENSE file for details.
- Documentation: docs.empathyfirstmedia.com
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Voice agent integration
- Multi-language support
- Advanced RAG with hybrid search
- Custom model fine-tuning
- Real-time collaboration features
- Advanced analytics dashboard
- Integration with popular CMS platforms
Built with β€οΈ by Empathy First Media Agency using Cloudflare Workers AI