Public API Reference
Complete endpoint documentation for the Flexlora AI Gateway. Base URL is https://api.flexlora.com/v1.
Authentication & Standard Headers
Every request requires a Bearer token in the Authorization header. Keys start with flx-.
Authorization: Bearer flx-live-1234567890abcdef12345678
Content-Type: application/json
Idempotency-Key: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d (Optional: prevents double-billing on network retry)
/v1/chat/completions
OpenAI-compatible chat completion endpoint supporting standard JSON payloads and real-time Server-Sent Events (SSE) streaming.
Request Parameters
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model alias, such as flexlora:fast or flexlora:smart. |
| messages | array | Yes | Array of message objects ({role: "system"|"user"|"assistant", content: string}). |
| stream | boolean | No | Defaults to false. Set to true to receive Server-Sent Events (SSE). |
| temperature | number | No | Sampling temperature between 0 and 2. Defaults to 0.7. |
| max_tokens | integer | No | Maximum number of completion tokens to generate. |
Request Payload (JSON)
{
"model": "flexlora:fast",
"messages": [
{ "role": "system", "content": "You are a concise engineering assistant." },
{ "role": "user", "content": "Write a high-throughput debounce function." }
],
"temperature": 0.7,
"max_tokens": 2048,
"stream": false
}Non-Streaming Response (200 OK)
{
"id": "chatcmpl-flx-9a8b7c6d",
"object": "chat.completion",
"created": 1729000000,
"model": "flexlora:fast",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here is a type-safe debounce function in TypeScript..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 142,
"total_tokens": 170
}
}Streaming Response (SSE: stream=true)
data: {"id":"chatcmpl-flx-101","object":"chat.completion.chunk","created":1729000000,"model":"flexlora:fast","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}
data: {"id":"chatcmpl-flx-101","object":"chat.completion.chunk","created":1729000000,"model":"flexlora:fast","choices":[{"index":0,"delta":{"content":"2, "},"finish_reason":null}]}
data: {"id":"chatcmpl-flx-101","object":"chat.completion.chunk","created":1729000000,"model":"flexlora:fast","choices":[{"index":0,"delta":{"content":"3, 5, 7, 11."},"finish_reason":"stop"}]}
data: [DONE]/v1/messages
Anthropic-compatible messages endpoint. Directly accepts Anthropic prompt schemas, top-level system instructions, and tool calling arrays.
Anthropic Request Payload (JSON)
{
"model": "flexlora:smart",
"max_tokens": 4096,
"system": "You are an expert technical architect.",
"messages": [
{ "role": "user", "content": "Explain how edge semantic caching works." }
],
"stream": false
}Anthropic Response Payload (200 OK)
{
"id": "msg-flx-5e4d3c2b",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Edge semantic caching operates close to users..."
}
],
"model": "flexlora:smart",
"stop_reason": "end_turn",
"usage": {
"input_tokens": 34,
"output_tokens": 380
}
}/v1/models
Returns all available active models, alias definitions, context windows, and capability flags on your account.
{
"object": "list",
"data": [
{
"id": "flexlora:fast",
"object": "model",
"created": 1729000000,
"owned_by": "flexlora",
"context_window": 128000,
"capabilities": ["chat", "streaming", "json_mode"]
},
{
"id": "flexlora:smart",
"object": "model",
"created": 1729000000,
"owned_by": "flexlora",
"context_window": 200000,
"capabilities": ["chat", "streaming", "vision", "reasoning"]
}
]
}Standard Error Envelopes & HTTP Status Codes
All gateway errors return a consistent JSON envelope with a machine-readable code and actionable message:
{
"error": {
"message": "Daily budget limit of $5.00 exceeded for this API key.",
"type": "budget_exceeded",
"code": "DAILY_BUDGET_EXCEEDED"
}
}| Status Code | Error Code | Resolution Guidance |
|---|---|---|
| 401 Unauthorized | INVALID_API_KEY | The API key is missing, revoked, or invalid. Verify your key in the console. |
| 402 Payment Required | INSUFFICIENT_BALANCE | Active FIFO credit batches are exhausted or expired. Top up credits via bKash or card. |
| 403 Forbidden | ACCOUNT_SUSPENDED | The account or key has been locked. Contact support@flexlora.com. |
| 429 Too Many Requests | BUDGET_EXCEEDED | The key has reached its configured daily or monthly spend cap. Adjust caps in console. |
| 429 Too Many Requests | RATE_LIMIT_EXCEEDED | Request concurrency or RPM limit reached. Back off with exponential jitter. |
| 502 Bad Gateway | UPSTREAM_ERROR | Upstream cluster timeout or failure. The gateway auto-retries across redundant replicas. |