Skip to content
LLMFLUX

Reference

API Reference

One gateway, compatible with both OpenAI and Anthropic — just change the base URL and keep your code.

Base URLs

OpenAI SDK / direct
https://api.llmflux.dev/v1
Anthropic / Claude Code
https://api.llmflux.dev

OpenAI clients append paths to {base}/v1. The Anthropic base has no /v1 — the SDK adds /v1/messages automatically.

Authentication

Send the gateway key in either header. If you send both, Authorization wins.

Authorization: Bearer $LLMFLUX_API_KEY
x-api-key: $LLMFLUX_API_KEY

No key → 401 missing_api_key. Invalid/expired/revoked key → 401 invalid_api_key. Out of credit → 402 quota_exhausted.

Endpoints

MethodPathPurpose
GET/v1Health check and endpoint discovery
GET/v1/modelsList all enabled catalogue models
GET/v1/usageRemaining quota and credit
POST/v1/chat/completionsChat completions (OpenAI format)
POST/v1/responsesResponses (OpenAI format)
POST/v1/messagesMessages (Anthropic format)
POST/v1/images/generationsImage generation (OpenAI format)

Models

The catalogue is administrator-controlled and changes with upstream synchronization. Call GET /v1/models with an active key for all enabled models. Copy an exact returned ID or its canonical root when present; metadata is descriptive, not a guarantee of endpoint or tool support.

Resolution: exact canonical ID, then configured display alias, then an ID with its first provider segment removed. auto falls back to an enabled ID ending in /auto, otherwise the first enabled catalogue row. Dots are not converted to dashes. Unknown or disabled models return 404 invalid_model. See the Models reference for details.

Requests

Replace model placeholders with compatible IDs from the live catalogue. Detailed references: Chat completions, Responses, Messages, Streaming and Errors.

Chat completions · OpenAI

curl https://api.llmflux.dev/v1/chat/completions \
  -H "Authorization: Bearer $LLMFLUX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [{ "role": "user", "content": "Hello" }]
  }'

Messages · Anthropic

curl https://api.llmflux.dev/v1/messages \
  -H "x-api-key: $LLMFLUX_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "max_tokens": 1024,
    "messages": [{ "role": "user", "content": "Hello" }]
  }'

Image generation · OpenAI

curl https://api.llmflux.dev/v1/images/generations \
  -H "Authorization: Bearer $LLMFLUX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_IMAGE_MODEL_ID",
    "prompt": "a glowing node graph, neon yellow",
    "size": "1024x1024"
  }'

Streaming

Set "stream": true — the gateway sends text/event-stream with no buffering (no-transform). If an error occurs after the stream has started (HTTP 200 already sent) it arrives as a frame:

event: error
data: {"error":{"message":"...","type":"api_error","code":"upstream_error"}}

Usage

GET /v1/usage returns account-wide usage and balance for the key's owner:

{
  "label": "gateway-key",
  "tokens_total": 1000000,
  "tokens_used": 12480,
  "tokens_remaining": 987520,
  "credits_remaining": 0.1487,
  "tokens_per_credit": 6666667,
  "status": "active"
}

Errors

Every error uses one envelope shape. The code also comes back as the header x-gateway-error-code. Provider error text is never leaked.

The backend defines context and policy codes, but generic upstream HTTP 400 currently maps to bad_request, not a provider-text-specific diagnosis. See the Errors reference for actual status mapping.

{
  "error": {
    "message": "Missing API key. Add header: Authorization: Bearer <your-key>",
    "type": "authentication_error",
    "code": "missing_api_key"
  }
}
CodeHTTPTypeMeaning
missing_api_key401authentication_errorNo API key in the header
invalid_api_key401authentication_errorKey invalid / expired / revoked
permission_denied403permission_errorKey not allowed for this model
quota_exhausted402invalid_request_errorOut of credit
rate_limit_exceeded429rate_limit_errorToo many requests — over the rate limit
context_length_exceeded400invalid_request_errorContext longer than allowed
content_policy_violation400invalid_request_errorContent violates policy
invalid_model404invalid_request_errorModel doesn't exist or key not allowed
payload_too_large413invalid_request_errorRequest body too large (default 25MB)
invalid_json400invalid_request_errorBody is not valid JSON
service_unavailable503api_errorService busy — please try again
gateway_timeout504api_errorTimed out reaching the provider
upstream_error502api_errorThe provider returned an error
internal_error500api_errorUnexpected gateway error