Layerr exposes a comprehensive HTTP API with 135 routes across 8 categories. All routes flow through the central server (server.ts) and are protected by gateway middleware unless otherwise noted.
All API responses follow a consistent envelope:
"timestamp" : " 2026-01-15T10:30:00Z " ,
"workspaceId" : " workspace-slug "
Error responses include:
"code" : " PROVIDER_UNAVAILABLE " ,
"message" : " All providers in fallback chain exhausted " ,
"details" : { "attempts" : 3 , "providers" : [ " openai " , " anthropic " , " ollama " ] }
All routes (except health checks) require a valid workspace API key passed via the Authorization: Bearer <key> header. Keys are validated by the gateway middleware (security/gateway/middleware.ts).
Per-workspace rate limits are enforced by the gateway:
Tier Requests/minute Burst Free 60 10 Standard 300 50 Enterprise 2000 200
These routes implement the OpenAI API specification, allowing existing clients to use Layerr as a drop-in replacement.
Route Method Description /v1/chat/completionsPOST Main chat completions endpoint. Accepts OpenAI-format requests, routes through Layerr intelligence /v1/modelsGET List available models across all configured providers /v1/models/{model}GET Get details for a specific model
Request body (OpenAI-compatible with Layerr extensions):
"messages" : [{ "role" : " user " , "content" : " Write a React component " }],
Layerr extensions (all optional):
Field Type Description layerr.strategystring Override strategy: cost, speed, quality, balanced layerr.fallbackstring Fallback mode: strict, relaxed, none layerr.explainboolean Include routing explanation in response headers layerr.workspacestring Target workspace slug (for admin keys)
Route Method Description /api/chatPOST Layerr-native chat endpoint with full orchestration /api/conversationsGET List conversation history /api/conversations/{id}GET Get a specific conversation /api/conversations/{id}DELETE Delete a conversation /api/conversations/{id}/messagesPOST Add a message to a conversation
The native chat endpoint provides more control than the OpenAI-compatible route:
Request body :
"messages" : [{ "role" : " user " , "content" : " Refactor this to TypeScript " }],
"files" : [ " src/App.js " , " src/types.ts " ]
Route Method Description /api/providersGET List all configured providers /api/providersPOST Add a new provider connection /api/providers/{id}GET Get provider details /api/providers/{id}PATCH Update provider configuration /api/providers/{id}DELETE Remove a provider /api/providers/{id}/healthGET Get provider health status /api/providers/{id}/testPOST Test provider connectivity /api/providers/discoverGET Auto-discover local providers (Ollama, etc.) /api/providers/capabilitiesGET Get capability matrix for all providers
"name" : " OpenAI Production " ,
"baseUrl" : " https://api.openai.com/v1 " ,
"models" : [ " gpt-4o " , " gpt-4o-mini " , " o1-preview " ],
Route Method Description /api/workspacesGET List workspaces /api/workspacesPOST Create a workspace /api/workspaces/{slug}GET Get workspace details /api/workspaces/{slug}PATCH Update workspace /api/workspaces/{slug}DELETE Delete workspace /api/workspaces/{slug}/healthGET Workspace health dashboard /api/workspaces/{slug}/limitsGET Current limit usage /api/workspaces/{slug}/limitsPATCH Update limits /api/workspaces/{slug}/runtimeGET Runtime profile /api/workspaces/{slug}/runtimePATCH Update runtime profile /api/workspaces/{slug}/restrictionsGET Provider restrictions /api/workspaces/{slug}/restrictionsPATCH Update restrictions
Route Method Description /api/strategiesGET List strategies /api/strategiesPOST Create custom strategy /api/strategies/{id}GET Get strategy details /api/strategies/{id}PATCH Update strategy /api/strategies/{id}DELETE Delete strategy /api/strategies/{id}/calibratePOST Trigger calibration for this strategy /api/workspaces/{slug}/strategyGET Get workspace default strategy /api/workspaces/{slug}/strategyPUT Set workspace default strategy
Route Method Description /api/tracesGET List execution traces /api/traces/{id}GET Get trace details /api/traces/{id}/replayPOST Replay a trace /api/traces/{id}/compare/{id2}GET Compare two traces /api/traces/{id}/explainGET Get routing explanation for trace /api/traces/{id}/economicsGET Get economic analysis for trace /api/traces/recentGET Get recent traces (with filtering) /api/traces/analyticsGET Trace analytics and trends
"workspaceId" : " my-project " ,
"classification" : " coding " ,
"primaryProvider" : " anthropic-prod " ,
"primaryModel" : " claude-sonnet-4 " ,
"fallbackChain" : [ " openai-prod " , " ollama-local " ],
"finalProvider" : " anthropic-prod " ,
"summary" : " Selected Claude Sonnet for high-quality code generation " ,
"providerRationale" : " Top quality score (0.92) for coding workloads "
Route Method Description /api/evaluation/calibrationGET Get latest calibration report /api/evaluation/calibrationPOST Run new calibration /api/evaluation/calibration/historyGET Calibration history /api/evaluation/qualityGET Quality metrics overview /api/evaluation/quality/providersGET Per-provider quality scores /api/evaluation/benchmarksGET List benchmark runs /api/evaluation/benchmarksPOST Run new benchmark /api/evaluation/benchmarks/{id}GET Get benchmark results /api/evaluation/codingPOST Submit code for evaluation /api/evaluation/coding/{id}GET Get code evaluation result /api/evaluation/outcomesGET Execution outcome metrics
Route Method Description /api/economics/summaryGET Economic summary for workspace /api/economics/providersGET Per-provider cost breakdown /api/economics/categoriesGET Cost by model category /api/economics/simulatePOST Run cost simulation /api/economics/simulate/{id}GET Get simulation result /api/economics/savingsGET Savings attribution report /api/economics/budgetGET Current budget status /api/economics/budgetPATCH Update budget settings /api/economics/insightsGET Economic insights and recommendations
"workspaceId" : " my-project " ,
"weeklyAlertThreshold" : 60.00 ,
"remainingBudget" : 65.50 ,
Route Method Description /api/admin/secretsGET List secrets (admin only) /api/admin/secretsPOST Add secret (admin only) /api/admin/secrets/{id}/rotatePOST Rotate secret (admin only) /api/admin/guardrailsGET Guardrail policies /api/admin/guardrailsPATCH Update guardrail policies /api/admin/auditGET Audit log /api/admin/tenancyGET Tenant diagnostics /api/healthGET System health check (no auth) /api/health/detailedGET Detailed health with component status /api/telemetryPOST Submit telemetry data
Category Count Prefix OpenAI-Compatible 4 /v1/Chat & Conversations 5 /api/chat, /api/conversationsProvider Management 9 /api/providersWorkspace Management 11 /api/workspacesStrategy 8 /api/strategiesExecution & Traces 7 /api/tracesEvaluation 10 /api/evaluationEconomics 9 /api/economicsSecurity & Admin 9 /api/admin, /api/healthTotal 135
Code HTTP Status Description UNAUTHORIZED401 Invalid or missing API key FORBIDDEN403 Insufficient permissions WORKSPACE_NOT_FOUND404 Workspace does not exist PROVIDER_UNAVAILABLE502 All providers exhausted in fallback chain RATE_LIMITED429 Workspace or provider rate limit exceeded BUDGET_EXCEEDED402 Workspace has exceeded its budget TIMEOUT504 Request exceeded timeout profile INVALID_STRATEGY400 Requested strategy does not exist GUARDRAIL_VIOLATION400 Request violates content policy CALIBRATION_PENDING503 System is recalibrating, try again later
Because Layerr implements the OpenAI API specification, it is compatible with:
OpenAI SDK (Python/JS), point base_url to your Layerr instance
LangChain , use OpenAI-compatible adapter
Vercel AI SDK , use createOpenAI with custom endpoint
Continue.dev , configure as custom OpenAI-compatible provider
Cursor , set API base URL in settings
API documentation generated from GitNexus route map. 135 routes indexed across 1,090 source files.