API reference · Chat Completions
Chat Completions.
The OpenAI Chat Completions dialect on the lx1 catalog. If your client speaks to OpenAI, it speaks to Layer X1 — swap the base URL and the key, keep everything else.
Endpoint
POST
/v1/chat/completionsAuthenticate with Authorization: Bearer lx1_.... Any model in the catalog is valid in model.
Request parameters
| Parameter | Type | Notes |
|---|---|---|
model | string · required | Any catalog id, e.g. lx1-gpt-oss-120b. |
messages | array · required | Chat history. Content can be a string or content parts; image parts (image_url, data URLs included) are accepted on vision models. |
max_tokens | integer | Output ceiling. On reasoning models, hidden reasoning counts against it — budget generously. |
temperature | number | Sampling temperature. |
top_p | number | Nucleus sampling. |
stop | string | string[] | Stop sequences. |
stream | boolean | SSE chunks when true. See Streaming. |
stream_options | object | { "include_usage": true } appends a final usage chunk. |
tools | array | Function tools. See Tool calling. |
tool_choice | string | object | auto, none, required, or a named function. |
response_format | object | JSON mode / json_schema. See Structured output. |
Example
curl https://api.layerx1.in/v1/chat/completions \
-H "authorization: Bearer $LAYERX1_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "lx1-gpt-oss-120b",
"messages": [
{ "role": "system", "content": "You are concise." },
{ "role": "user", "content": "Say hi." }
]
}'{
"id": "chatcmpl_...",
"object": "chat.completion",
"model": "lx1-gpt-oss-120b",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "Hi." },
"finish_reason": "stop"
}],
"usage": { "prompt_tokens": 14, "completion_tokens": 3, "total_tokens": 17 }
}Response fields
| Field | Notes |
|---|---|
choices[].message | The assistant turn — content, and tool_calls when the model calls a tool. |
choices[].finish_reason | stop, length (hit max_tokens), or tool_calls. |
usage | Prompt, completion, and total token counts for the request. |
Streaming
With stream: true the response is Server-Sent Events: incremental chat.completion.chunk objects, terminated by data: [DONE].
curl -N https://api.layerx1.in/v1/chat/completions \
-H "authorization: Bearer $LAYERX1_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "lx1-gpt-oss-120b",
"stream": true,
"stream_options": { "include_usage": true },
"messages": [{ "role": "user", "content": "Count to five." }]
}'Errors
Failures return standard status codes with OpenAI-shaped bodies — match on the status, retry on 429/5xx with backoff. Full reference: Errors.
Note
Requesting vision input on a text-only model is a 400; check capability flags on the model catalog first — only lx1-sonnet-4.6 reads images.