Overview
The AI Proxy Backend is a comprehensive API gateway built with Next.js, providing unified access to Google Gemini AI models.
Unified AI Interface
Single API endpoint for text, image, and vision tasks.
JWT Authentication
Clerk-based verification with secure user context.
Quota Enforcement
Tier-based limits and real-time usage tracking.
Gamified Systems
XP, levels, and achievements integrated via Convex.
Authentication
All protected endpoints require a valid Clerk JWT token in the Authorization header.
Rate Limiting
To ensure system stability, we enforce sliding window rate limits based on IP address.
AI Proxy Endpoints
/api/ai/proxyUnified endpoint for multiple AI task types.
{
"type": "text" | "image" | "compare",
"input": {
"prompt": "Your content here..."
}
}/api/analyzer/evaluate-imagesDetailed scoring of generated vs target images.
{
"input": {
"userImageUrl": "...",
"expectedImageUrl": "..."
}
}User Data Endpoints
/api/user/usageRetrieve current user quota and tier limits.
/api/user/game-stateFetch level progression and gamification state.
/api/v1/user/syncFull profile and progress synchronization.
Analytics & System
/api/analytics/eventLog custom user behavior and application events.
/api/healthCheck infrastructure and sub-system status.