API reference · Messages

Messages.

The Anthropic Messages dialect on the lx1 catalog — the surface Claude Code and the Anthropic SDKs speak. Content blocks, tools, vision, and PDFs, with SSE streaming.

Endpoint

POST/v1/messages

Authenticate with x-api-key: lx1_... (a bearer token also works). Any model in the catalog is valid in model.

Request parameters

ParameterTypeNotes
modelstring · requiredAny catalog id, e.g. lx1-sonnet-4.6.
max_tokensinteger · requiredOutput ceiling. On reasoning models, hidden reasoning counts against it — budget generously.
messagesarray · requiredAlternating turns. Content is a string or an array of blocks: text, image (base64), document (PDF), tool_result.
systemstring | arraySystem prompt.
toolsarrayTool definitions with JSON-schema input. See Tool calling.
tool_choiceobject{ "type": "auto" | "any" | "tool" }.
temperaturenumberSampling temperature.
top_pnumberNucleus sampling.
stop_sequencesstring[]Custom stop sequences.
streambooleanAnthropic SSE event stream when true.
Note

Image blocks and PDF document blocks are read by lx1-sonnet-4.6— the catalog's vision model. Other models reject them with a 400.

Example

curl https://api.layerx1.in/v1/messages \
  -H "x-api-key: $LAYERX1_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "lx1-sonnet-4.6",
    "max_tokens": 512,
    "system": "You are concise.",
    "messages": [{ "role": "user", "content": "Say hi." }]
  }'
Create a message
{
  "id": "msg_...",
  "type": "message",
  "role": "assistant",
  "model": "lx1-sonnet-4.6",
  "content": [{ "type": "text", "text": "Hi." }],
  "stop_reason": "end_turn",
  "usage": { "input_tokens": 14, "output_tokens": 3 }
}
Response (shape)

Response fields

FieldNotes
contentArray of blocks — text, and tool_use when the model calls a tool.
stop_reasonend_turn, max_tokens, stop_sequence, or tool_use.
usageInput and output token counts for the request.

Streaming

With stream: true the response is the Anthropic SSE event sequence — message_start, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop — exactly what the Anthropic SDKs expect.

curl -N https://api.layerx1.in/v1/messages \
  -H "x-api-key: $LAYERX1_API_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "lx1-gpt-oss-120b",
    "max_tokens": 256,
    "stream": true,
    "messages": [{ "role": "user", "content": "Count to five." }]
  }'
Stream a message

Errors

Failures return standard status codes with Anthropic-shaped bodies ({ "type": "error", "error": { ... } }). Retry on 429/5xx with backoff and honor retry-after. Full reference: Errors.