Skip to main content

Base URL

https://api.lightweight.one/v1
All API requests must be made over HTTPS.

Authentication

Authenticate every request with a Bearer token in the Authorization header. Keys start with lw_sk_.
Authorization: Bearer lw_sk_your-key-here
Get your key from the Dashboard.
Never expose your API key in client-side code or public repositories. Keep it server-side or in environment variables.

Endpoints

POST /v1/chat/completions

The primary endpoint — fully compatible with the OpenAI Chat Completions API. Works with every model in the catalog regardless of provider.
curl https://api.lightweight.one/v1/chat/completions \
  -H "Authorization: Bearer lw_sk_your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is the capital of France?"}
    ],
    "max_tokens": 200
  }'
Key parameters:
ParameterTypeRequiredDescription
modelstringYesModel ID from the catalog
messagesarrayYesArray of message objects with role and content
max_tokensintegerNoMaximum tokens to generate
temperaturenumberNoSampling temperature (0–2)
streambooleanNoEnable server-sent events streaming
top_pnumberNoNucleus sampling parameter
stopstring/arrayNoStop sequence(s)

POST /v1/messages

Native Anthropic Messages API passthrough. Use this if you prefer the Anthropic SDK format.
curl https://api.lightweight.one/v1/messages \
  -H "Authorization: Bearer lw_sk_your-key-here" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4.5",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "Explain quantum computing in simple terms."}
    ]
  }'

POST /v1/responses

OpenAI Responses API passthrough. Use this for the newer OpenAI Responses format.
curl https://api.lightweight.one/v1/responses \
  -H "Authorization: Bearer lw_sk_your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4",
    "input": "What is the capital of France?"
  }'

GET /v1/models

Returns the live catalog of all available models. See Models API for full schema details.
curl https://api.lightweight.one/v1/models \
  -H "Authorization: Bearer lw_sk_your-key-here"

GET /v1/usage

Check your current token usage and quota.
curl https://api.lightweight.one/v1/usage \
  -H "Authorization: Bearer lw_sk_your-key-here"
Example response:
{
  "used": 1250000,
  "quota": 10000000,
  "remaining": 8750000,
  "resets_at": "2026-04-01T00:00:00Z"
}

Error Codes

Status CodeMeaningDescription
401UnauthorizedMissing or invalid API key. Ensure your Authorization header contains a valid lw_sk_ key.
403ForbiddenYour key does not have access to the requested model or resource.
429Rate LimitedYou’ve exceeded your plan’s requests-per-minute limit. Check the Retry-After header and wait before retrying.
502Bad GatewayThe upstream provider returned an error. Retry after a brief delay.
Error response format:
{
  "error": {
    "message": "Rate limit exceeded. Please retry after 12 seconds.",
    "type": "rate_limit_error",
    "code": 429
  }
}
When you receive a 429, read the Retry-After response header — it tells you exactly how many seconds to wait before your next request.