API reference · OpenAI
Chat completions
OpenAI-format inference through your LLMFLUX gateway key.
Endpoint
POST /v1/chat/completions
Send Content-Type: application/json and either Authorization: Bearer YOUR_KEY or x-api-key: YOUR_KEY. Authorization takes precedence. Use a server-side environment variable, never a browser bundle.
Request body
| Field | Behavior |
|---|---|
model | Required gateway selector. An enabled canonical ID or configured alias from GET /v1/models. |
messages | OpenAI-format input, validated by the upstream provider. |
stream | Only literal JSON true enables SSE. Otherwise the gateway explicitly sends false upstream. |
Send messages as an array of role/content objects. A typical non-streaming result contains choices[].message and usage. Tools, image content, structured output and generation controls depend on the selected model and provider.
Example request
Replace YOUR_MODEL_ID with a compatible live ID. SDK examples read LLMFLUX_MODEL and LLMFLUX_API_KEY from your environment.
One gateway key reaches every enabled provider through this path.
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 from LLMFLUX"
}
],
"stream": false
}'Response and streaming
Successful non-streaming requests return HTTP 200 and the provider JSON payload, not a new gateway response schema. Token usage is recorded against your account. Set stream: true for SSE streaming.
For chat streams, the gateway merges stream_options and forces include_usage: true so the provider can send terminal usage.
Errors and limits
Inference requires an active key, any required Telegram verification, a positive account balance and available plan allowance. The per-user inference throttle is 120 requests per minute across keys. Bodies are limited to 25 MB. See error codes for handling 401, 402, 403, 404, 429 and provider failures.