Skip to main content
POST
/
api
/
organizations
/
{orgId}
/
ai
/
chat
/
completions
Create chat completion
curl --request POST \
  --url https://platform.kodexa.ai/api/organizations/{orgId}/ai/chat/completions \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "messages": [
    {
      "content": "<string>",
      "role": "system"
    }
  ],
  "model": "<string>",
  "max_tokens": 123,
  "n": 123,
  "stop": [
    "<string>"
  ],
  "stream": true,
  "temperature": 123,
  "top_p": 123
}
'
{
  "choices": [
    {
      "finish_reason": "<string>",
      "index": 123,
      "message": {
        "content": "<string>",
        "role": "system"
      }
    }
  ],
  "created": 123,
  "id": "<string>",
  "model": "<string>",
  "object": "<string>",
  "usage": {
    "completion_tokens": 123,
    "prompt_tokens": 123,
    "total_tokens": 123
  }
}

Authorizations

x-api-key
string
header
required

API key for authentication. Create one from the Kodexa platform UI under Settings > Access Tokens.

Path Parameters

orgId
string<uuid>
required

Organization UUID. The authenticated user must be a member of this organization.

Body

application/json

Request body for creating a chat completion. Compatible with the OpenAI Chat Completions API.

messages
object[]
required

A list of messages comprising the conversation.

model
string
required

ID of the model to use (e.g., 'gpt-4', 'claude-3-sonnet').

max_tokens
integer

Maximum number of tokens to generate.

n
integer

Number of completions to generate.

stop
string[]

Sequences where the API will stop generating.

stream
boolean

If true, partial message deltas are sent as server-sent events (SSE).

temperature
number<float>

Sampling temperature between 0 and 2.

top_p
number<float>

Nucleus sampling parameter.

Response

Chat completion response. When stream: true, the response is a stream of server-sent events with Content-Type: text/event-stream.

Response from the chat completion endpoint. Compatible with the OpenAI Chat Completions API response format.

choices
object[]
created
integer<int64>

Unix timestamp of when the completion was created.

id
string

Unique identifier for the completion.

model
string

The model used for the completion.

object
string

Object type, always 'chat.completion'.

usage
object