Skip to content
SupportLogin
Create a chat completion

Create a chat completion

POST/api/v1/chat/completions

OpenAI-compatible Chat Completions. Supports streaming, function tools, structured output, and image and file input.

Body ParametersJSONExpand Collapse
model: string

A model id from GET /models.

minLength1
maxLength128
messages: array of object { role, content, name } or object { role, content, name } or object { role, content, name } or 2 more
One of the following:
ChatCompletionSystemMessageDto object { role, content, name }
role: "system"
content: string or array of object { type, text }

Text, or a list of text parts.

One of the following:
string
array of object { type, text }
type: "text"
text: string
name: optional string
minLength1
maxLength64
ChatCompletionDeveloperMessageDto object { role, content, name }
role: "developer"
content: string or array of object { type, text }

Text, or a list of text parts.

One of the following:
string
array of object { type, text }
type: "text"
text: string
name: optional string
minLength1
maxLength64
ChatCompletionUserMessageDto object { role, content, name }
role: "user"
content: string or array of object { type, text } or object { type, image_url } or object { type, file }

Text, or a list of text, image and file parts.

One of the following:
string
array of object { type, text } or object { type, image_url } or object { type, file }
One of the following:
ChatCompletionTextPartDto object { type, text }
type: "text"
text: string
ChatCompletionImagePartDto object { type, image_url }
type: "image_url"
image_url: object { url, detail }
url: string

An https URL or an inline data:image/... URL.

detail: optional "auto" or "low" or "high"
One of the following:
"auto"
"low"
"high"
ChatCompletionFilePartDto object { type, file }
type: "file"
file: object { file_data, filename }
file_data: string

The file as an inline data URL. File IDs are not supported.

filename: string
minLength1
maxLength256
name: optional string
minLength1
maxLength64
ChatCompletionAssistantMessageDto object { role, content, name, 4 more }
role: "assistant"
content: optional string or array of object { type, text }

Null when the turn is only tool calls. A turn needs content, a refusal, reasoning or tool_calls.

One of the following:
string
array of object { type, text }
type: "text"
text: string
name: optional string
minLength1
maxLength64
refusal: optional string
tool_calls: optional array of object { id, type, function }
id: string
type: "function"
function: object { name, arguments }
name: string
minLength1
maxLength64
arguments: string

The arguments as a JSON-encoded string.

reasoning_content: optional string

The model’s earlier reasoning, replayed so it can continue from it.

reasoning: optional string

Alias of reasoning_content.

ChatCompletionToolMessageDto object { role, content, tool_call_id }
role: "tool"
content: string or array of object { type, text }

Text, or a list of text parts.

One of the following:
string
array of object { type, text }
type: "text"
text: string
tool_call_id: string
minLength1
tools: optional array of object { type, function }
type: "function"

Only function tools are supported.

function: object { name, description, parameters, strict }
name: string
minLength1
maxLength64
description: optional string
parameters: optional map[unknown]

The function parameters as a JSON Schema object.

strict: optional boolean
tool_choice: optional "none" or "auto" or "required" or object { type, function }

Requires tools. A named function must be one of tools.

One of the following:
"none" or "auto" or "required"
One of the following:
"none"
"auto"
"required"
ChatCompletionNamedToolChoiceDto object { type, function }
type: "function"
function: object { name }
name: string
minLength1
maxLength64
parallel_tool_calls: optional boolean
response_format: optional object { type, json_schema }
type: "text" or "json_object" or "json_schema"
One of the following:
"text"
"json_object"
"json_schema"
json_schema: optional object { name, description, schema, strict }

Required when type is json_schema, and only then.

name: string
minLength1
maxLength64
description: optional string
schema: optional map[unknown]
strict: optional boolean
reasoning_effort: optional "none" or "minimal" or "low" or 4 more

How much the model reasons before answering. Levels vary by model; max is beyond OpenAI’s set and is supported by GLM and DeepSeek V4.

One of the following:
"none"
"minimal"
"low"
"medium"
"high"
"xhigh"
"max"
stream: optional boolean

Stream the reply as server-sent events.

stream_options: optional object { include_usage }

Requires stream: true.

include_usage: optional boolean

Send a final chunk carrying token usage.

max_tokens: optional number

Do not send together with max_completion_tokens.

minimum1
maximum2147483647
max_completion_tokens: optional number

Output token limit, reasoning included. Do not send together with max_tokens.

minimum1
maximum2147483647
temperature: optional number
minimum0
maximum2
top_p: optional number
minimum0
maximum1
frequency_penalty: optional number
minimum-2
maximum2
presence_penalty: optional number
minimum-2
maximum2
seed: optional number
stop: optional string or array of string
One of the following:
string
array of string
metadata: optional map[string]

Up to 16 string pairs (keys up to 64 characters). Kept with a stored completion; never sent to the model provider.

user: optional string

Accepted for OpenAI compatibility; not sent to the model provider.

maxLength256
safety_identifier: optional string

Accepted for OpenAI compatibility; not sent to the model provider.

maxLength64
store: optional boolean

Keep the completion so it can be retrieved later.

ReturnsExpand Collapse
ChatCompletion object { id, object, created, 4 more }
id: string
object: "chat.completion"
created: number

Unix time in seconds.

model: string
system_fingerprint: optional string
choices: array of object { index, finish_reason, message }
index: 0
finish_reason: "stop" or "length" or "tool_calls" or 2 more
One of the following:
"stop"
"length"
"tool_calls"
"content_filter"
"function_call"
message: ChatCompletionMessage { role, content, refusal, 2 more }
role: "assistant"
content: string
refusal: optional string
reasoning_content: optional string

The model’s reasoning, for models that reason.

tool_calls: optional array of object { id, type, function }
id: string
type: "function"
function: object { name, arguments }
name: string
minLength1
maxLength64
arguments: string

The arguments as a JSON-encoded string.

usage: ChatCompletionUsage { prompt_tokens, completion_tokens, total_tokens, 2 more }
prompt_tokens: number
completion_tokens: number
total_tokens: number
prompt_tokens_details: optional object { cached_tokens, audio_tokens }
cached_tokens: optional number
audio_tokens: optional number
completion_tokens_details: optional object { reasoning_tokens, audio_tokens, accepted_prediction_tokens, rejected_prediction_tokens }
reasoning_tokens: optional number
audio_tokens: optional number
accepted_prediction_tokens: optional number
rejected_prediction_tokens: optional number

Create a chat completion

curl https://api.prod.adaptionlabs.ai/api/v1/chat/completions \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $ADAPTION_API_KEY" \
    -d '{
          "model": "glm-5.2",
          "messages": [
            {
              "role": "system",
              "content": "string"
            }
          ]
        }'
{
  "id": "id",
  "object": "chat.completion",
  "created": 0,
  "model": "model",
  "system_fingerprint": "system_fingerprint",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "content",
        "refusal": "refusal",
        "reasoning_content": "reasoning_content",
        "tool_calls": [
          {
            "id": "id",
            "type": "function",
            "function": {
              "name": "name",
              "arguments": "arguments"
            }
          }
        ]
      }
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "audio_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "audio_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  }
}
Returns Examples
{
  "id": "id",
  "object": "chat.completion",
  "created": 0,
  "model": "model",
  "system_fingerprint": "system_fingerprint",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "content",
        "refusal": "refusal",
        "reasoning_content": "reasoning_content",
        "tool_calls": [
          {
            "id": "id",
            "type": "function",
            "function": {
              "name": "name",
              "arguments": "arguments"
            }
          }
        ]
      }
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0,
    "prompt_tokens_details": {
      "cached_tokens": 0,
      "audio_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0,
      "audio_tokens": 0,
      "accepted_prediction_tokens": 0,
      "rejected_prediction_tokens": 0
    }
  }
}