ApilageAI Developer API Documentation
Last updated: February 19, 2026
Official documentation for ApilageAI’s Sri Lanka focused developer API. Learn how to authenticate, stream responses, manage rate limits, and price tokens correctly with system text included.
Contents
Base URL: https://apilageai.lk
Use the developer portal at https://apilageai.lk/developers to create API keys, manage allowed domains, and monitor usage.
Overview
The ApilageAI Developer API delivers streaming and direct text responses optimized for Sri Lankan education workflows, multilingual support, and custom system instructions. Charges are calculated per 1M tokens and include system text.
Quickstart
- const API_KEY = "YOUR_API_KEY";
- const BASE_URL = "BASE_URL";
- const resp = await fetch(`${BASE_URL}/api/developer/text`, {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- "X-API-Key": API_KEY
- },
- body: JSON.stringify({
- prompt: "Explain Newton\u2019s laws",
- model: "pro",
- system: "You are a tutor."
- })
- });
- const data = await resp.json();
- console.log(data.text);
Authentication
- Send your API key in the `X-API-Key` header.
- API keys are limited to 10 per account.
- Each key can whitelist up to 5 allowed domains.
- Developer API requests require a positive ApilageAI balance.
Endpoints
POST /api/developer/text
Direct response endpoint.
- Body: prompt, model, system (optional), temperature (optional), max_tokens (optional)
- Response: text, usage (token + cost breakdown)
POST /api/developer/stream
Streaming SSE endpoint for real-time output.
Streaming (SSE)
Streaming responses are sent as Server-Sent Events. Each `data:` event contains a JSON payload with `delta`. A final `event: done` includes usage totals and cost.
data: {"delta":"First chunk"}\n\n data: {"delta":"More text"}\n\n event: done data: {"usage":{"total_tokens":1234,"total_cost_lkr":12.34}}\n\n Pricing (LKR per 1M tokens)
| Model | Input | Output |
|---|---|---|
| free | 1499.00 | 1299.00 |
| pro | 1999.00 | 1899.00 |
| super | 3599.00 | 3299.00 |
| master | 7999.00 | 7000.00 |
| loard | 10000.00 | 8999.00 |
System text tokens are included in input charges and are deducted from your ApilageAI balance.
Rate Limits
| Model | TPM | RPD |
|---|---|---|
| free | 1,000,000 | 1,500 |
| pro | 1,000,000 | 1,500 |
| super | 1,000,000 | 1,500 |
| master | 1,000,000 | 1,500 |
| loard | 700 | 1,000 |
Allowed Domains
Each API key can store up to 5 allowed domains (e.g., `example.com`, `app.example.com`, or `https://app.example.com`). Requests from other origins are blocked.
Errors
All errors return JSON in the format {"e":true,"m":"...","code":"..."}. Streaming errors are sent as event: error with the same payload.
- 400 PROMPT_REQUIRED, PROMPT_TOO_LONG, SYSTEM_TOO_LONG.
- 405 METHOD_NOT_ALLOWED.
- 401 API_KEY_REQUIRED, INVALID_API_KEY.
- 403 API_KEY_DISABLED, ORIGIN_NOT_ALLOWED, KEY_LEAK_DETECTED.
- 402 INSUFFICIENT_BALANCE.
- 429 TPM_LIMIT, RPD_LIMIT.
- 500 GENERATION_FAILED.
Security & Leak Detection
ApilageAI automatically detects suspicious API key exposure (for example, public code repository leaks) and may disable the key to protect your balance. Always rotate keys if you suspect a leak.