AI API
Endpoints for interacting with AI models through a unified provider layer. These endpoints are served by the backend API service, not the web application. They are available at the backend base URL, which may differ from the web API base URL depending on your deployment.These endpoints are internal backend endpoints and are not exposed through the web application’s
/api routes. The health check (GET /api/ai/health) and model listing endpoints (GET /api/ai/models, GET /api/ai/models/:provider) are public and do not require authentication — they return non-sensitive data for status monitoring and pricing discovery. All other endpoints require bearer token (API key) authentication. The chat and cost estimation endpoints additionally require a valid subscription plan. All POST requests must include the Content-Type: application/json header.Health check
Response
status field is healthy when all providers are reachable and degraded when one or more are down.
Error response
When one or more providers fail, the response usesstatus: "error" and includes the error message:
List models
Response
Errors
List models by provider
Path parameters
Response
Select model
Request body
Response
Errors
Chat completion
The chat endpoint uses header-based authentication. Access control is enforced through the
x-user-plan and x-stripe-subscription-id headers rather than JWT verification. Admin emails (configured via ADMIN_EMAILS) bypass both plan and subscription requirements.Request headers
The following headers are required for plan enforcement:Request body
Example request
Response
Returns a structured response with the following shape:Errors
402 error example
403 error example
429 error example
Token quotas
Each plan enforces a monthly token budget across all AI chat requests. Token usage (input + output) is tracked per user and checked before each request. When your usage reaches the plan limit, subsequent requests are rejected with a429 status and a QUOTA_EXCEEDED error code. Quotas reset at the start of each calendar month.
The
free plan has a token limit of zero. All agent usage requires a paid subscription.Plan-based model access
Each subscription plan grants access to a specific set of AI models. The chat endpoint enforces these limits automatically.Admin users are automatically granted
network-level access regardless of their subscription plan.Model fallbacks
Each AI provider is configured with a primary model and a fallback model. When the primary model is unavailable or returns an error, the system automatically retries the request using the fallback model.minimax (MiniMax/MiniMax-Text-01) is available in the provider configuration map but is not currently supported in the model fallback chain. It may be enabled in a future release.model field.
Task-based model tiers
In addition to provider-level fallbacks, the backend AI service uses a tier-based routing system that selects models based on the type of work being performed. Each tier defines a primary model and two fallback models. If the primary model fails or times out, the system tries each fallback in order.
Each model attempt has a timeout of 30 seconds by default. You can override this with the
AI_MODEL_TIMEOUT_MS environment variable. All tier-based requests are routed through OpenRouter.