Chat

OpenAI-compliant chat completion operations.

Create chat completion

post

Stream a conversation turn using the OpenAI Chat Completion format. This endpoint translates the request into an NLX conversation turn and streams back the app's response.

Authorizations
AuthorizationstringRequired

Standard OpenAI-style authentication. Your NLX API Key should be passed here.

Path parameters
deploymentKeystringRequired

The unique key identifying the AI app deployment.

channelKeystringRequired

The unique key identifying the specific channel. Must include the language code suffix (e.g., -en-US, -es-MX).

Example: xxxxxxxx-en-US
Body
modelstringRequired

Used to pass the session identifier. Expected format: "nlx:{conversationId}". If the conversationId is omitted (e.g., just "nlx"), a new UUID will be generated.

Example: nlx:550e8400-e29b-41d4-a716-446655440000
streambooleanOptional

If set, partial message deltas will be sent using Server-Sent Events. This API is optimized for streaming.

Default: true
Responses
200

Server-sent events stream. The response is streamed as a series of JSON objects prefixed with "data: ".

text/event-stream
post
/{deploymentKey}/{channelKey}/chat/completions
POST /v1/{deploymentKey}/{channelKey}/chat/completions HTTP/1.1
Host: apps.nlx.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 114

{
  "model": "nlx:550e8400-e29b-41d4-a716-446655440000",
  "messages": [
    {
      "role": "system",
      "content": "text"
    }
  ],
  "stream": true
}
{
  "id": "text",
  "object": "chat.completion.chunk",
  "created": 1,
  "model": "text",
  "system_fingerprint": "text",
  "choices": [
    {
      "index": 1,
      "delta": {
        "role": "system",
        "content": "text"
      },
      "logprobs": {},
      "finish_reason": "stop"
    }
  ]
}

Last updated