Authentication
Send Authorization: Bearer with an lnx_live_ or lnx_dev_ key. The secret is shown once and only its SHA-256 hash is stored. Each key belongs to one project and has one billing scope.
Manage API keyspacing_limits
Deducts only from a purchased PLUS, PRO or MAX plan’s monthly, 5-hour and weekly token counters. Invitation-trial tiers do not grant pacing access. No automatic gift or wallet fallback.
token_pool
Deducts only from the active LaunchTrialGrant invitation vault, including after a plan purchase. Missing, expired, revoked or exhausted gifts return 429. No plan or wallet fallback.
Chat completions
POST /api/v1/chat/completionsUse model lunax-chat, messages with system/user/assistant roles and string content, optional max_tokens (1–8192, default 1024), temperature (0–2), and stream (default false). The alias uses the operator-configured active model; arbitrary upstream model IDs are refused. Streaming returns SSE chat.completion.chunk events and [DONE]. Set stream_options.include_usage=true to receive the usage chunk.
curl https://lunax.co/api/v1/chat/completions \
-H "Authorization: Bearer $LUNAX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"lunax-chat","messages":[{"role":"user","content":"Hello"}],"max_tokens":1024,"stream":false}'Browser key management
These routes require an active dashboard session and CSRF protection for mutations, rather than an LLM Bearer key. POST accepts name, projectId, billingScope, environment (live/dev), and expiresInDays (1–365). Only project owners and members may create keys. The default expiry is 90 days; at most 20 active LLM keys per account. DELETE revokes the key.
- GET /api/user/api-keys
- POST /api/user/api-keys
- DELETE /api/user/api-keys/{keyId}
Errors and quota limits
401: invalid, expired or revoked key or inactive account. 403: key lacks an LLM billing capability. 404: project access removed. 400: invalid schema or context too long. 413: request exceeds 64 KiB. 429: selected quota unavailable, with Retry-After. Upstream/configuration failures return 502/503. Development keys consume real tokens under the same policy.
Before inference we reserve a conservative UTF-8 prompt ceiling plus max_tokens, then settle measured input/output usage and release unused tokens. A request may receive 429 if its full reservation does not fit; reduce max_tokens or prompt size. If a non-streaming request fails before usage is known, its reservation remains for operator reconciliation. For interrupted streams, settlement uses measured usage when available, otherwise a bounded estimate; a failed settlement can leave the reservation in place.