Light
Developer Reference

Light API Technical Documentation

Technical reference for HTTP endpoints, authentication headers, Server-Sent Events (SSE) streaming, pre-request quota reservation and response status handling.

Protocol and tool support depend on the model and provider. A connected catalog entry does not mean every feature has been verified.

Base URL & Authentication

Public API endpoint from the server configuration.

Send all API requests to the base prefix https://api.lightapi.app/v1. Authenticate with your secret key using the Authorization: Bearer <API_KEY> header (supported on both OpenAI and Anthropic routes) or x-api-key: <API_KEY> with anthropic-version: 2023-06-01 (for Anthropic Messages API).

curl https://api.lightapi.app/v1/models \
  -H "Authorization: Bearer $LGHT_API_KEY"

GET /v1/models returns the list of models permitted for your key and active in your wallet's billing mode.

OpenAI Protocol: Chat Completions

POST /v1/chat/completions

Standard endpoint for multi-turn chat completions, supporting both synchronous JSON responses and token-by-token streaming.

curl https://api.lightapi.app/v1/chat/completions \
  -H "Authorization: Bearer $LGHT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash",
    "max_tokens": 512,
    "messages": [
      {"role": "user", "content": "Explain the difference between a process and a thread briefly."}
    ]
  }'

Server-Sent Events (SSE) Streaming

Pass "stream": true to receive tokens over SSE as they are generated. If the client disconnects after text generation has started, consumed tokens are reconciled and settled in the usage ledger.

Anthropic Protocol: Messages API

POST /v1/messages

Compatible endpoint for tools and SDKs (including Claude Code) that use the Anthropic Messages specification.

curl https://api.lightapi.app/v1/messages \
  -H "Authorization: Bearer $LGHT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4.1-flash",
    "max_tokens": 512,
    "messages": [
      {"role": "user", "content": "Review the time complexity of binary search."}
    ]
  }'

Quota Reservation, Settlement & Error Handling

Upper-Bound Reservation Without Debt

Before forwarding a paid text request to a supplier, the gateway reserves the upper-bound input and output cost rounded up. If the wallet balance or key spending cap is insufficient, the request is rejected before calling the supplier (HTTP 403/402) with zero charge. Unused reservation is refunded automatically when the response completes.

Crash Recovery Journal

Active reservations are recorded in a persistent journal. If the gateway restarts before a response starts or mid-stream, unsettled reservations are returned to the wallet while confirmed charges remain intact.

Explicit Outcomes & No Paid Auto-Retries

Empty responses, reasoning-only outputs (reasoning_limit), length truncation (finish_reason=length), provider content filtering and stream interruptions receive distinct status labels. Partial responses are never disguised as complete, and failed paid generations are never retried automatically at your expense.

Free Policy & Encrypted History

Free tier: up to 10 requests/day for guests and up to 50 when signed in (up to 2024 input tokens and 512 output tokens). Free chat retains the last 5 messages per conversation, while paid chat saves full conversation history. Website chats are stored until you delete them manually. Paid chat retains conversation history; free chat retains up to the last 5 messages. Deleting a chat removes its messages and title from the live store. The Light API is strictly no-log for content: prompt and response text is not saved. Only operational and billing metadata remains: time, model, tokens, cost, key, IP address and processing status. Deleting a conversation from the live store does not immediately remove its previous data from existing backups. No-log applies to storage by Light. Requests are sent to the selected provider to generate an answer; providers and Telegram have their own data handling policies.