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/completions

Authenticate with Authorization: Bearer lx1_.... Any model in the catalog is valid in model.

Request parameters

ParameterTypeNotes
modelstring · requiredAny catalog id, e.g. lx1-gpt-oss-120b.
messagesarray · requiredChat history. Content can be a string or content parts; image parts (image_url, data URLs included) are accepted on vision models.
max_tokensintegerOutput ceiling. On reasoning models, hidden reasoning counts against it — budget generously.
temperaturenumberSampling temperature.
top_pnumberNucleus sampling.
stopstring | string[]Stop sequences.
streambooleanSSE chunks when true. See Streaming.
stream_optionsobject{ "include_usage": true } appends a final usage chunk.
toolsarrayFunction tools. See Tool calling.
tool_choicestring | objectauto, none, required, or a named function.
response_formatobjectJSON 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." }
    ]
  }'
Create a chat completion
{
  "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 (shape)

Response fields

FieldNotes
choices[].messageThe assistant turn — content, and tool_calls when the model calls a tool.
choices[].finish_reasonstop, length (hit max_tokens), or tool_calls.
usagePrompt, 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." }]
  }'
Stream tokens as they generate

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.