Create a model response for a chat conversation. Request and response shapes follow OpenAI Chat Completions. Unlisted top-level fields are passed through when safe.

POST https://51kik.com/v1/chat/completions

Authentication

Authorization: Bearer YOUR_API_KEY — required.

Recommended headers

HeaderDescription
Content-Typeapplication/json
Acceptapplication/json, or text/event-stream when stream: true
x-trace-idOptional correlation id (max 256 chars)
x-user-idOptional end-user id in your system
x-agent-nameOptional agent name (recorded in usage)

Request body

FieldRequiredDescription
modelyesCatalog id from GET /models
messagesyesArray, min length 1
streamnotrue → SSE (chat.completion.chunk)
max_tokensnoMax output tokens
temperature, top_pnoSampling
stopnoString or string array
frequency_penalty, presence_penaltynoOpenAI-compatible
seednoInteger seed when upstream supports
toolsnoUp to 64 function tools
tool_choicenonone / auto / required or named function
pdf_preprocessnoGateway PDF extension (below)
extra_bodynoJSON object merged into upstream (OpenAI-compatible routes)
stream_optionsnoGateway always enables include_usage on streams

Limit: JSON body up to 32 MB.

messages[]

roleNotes
system, user, assistant, developerStandard
toolNon-empty tool_call_id required
assistantMay include tool_calls; content may be null when only tools

content may be a string, null (treated as empty), or an array of parts for multimodal user messages.

User content parts

typeDescription
textPlain text
image_url{ "url": "...", "detail": "auto" }
input_audioAudio input (OpenAI wire)
input_fileOne of: file_id (Files API), file_url (http/https), or file_data + filename

Legacy file / video_url parts return 400.

pdf_preprocess (gateway)

{ "engine": "native" }
engineBehavior
nativeDefault — forward unchanged
ocrOCR then send upstream
markdownExtract as Markdown

Optional: max_pages (≤ 50), merge_pages.

Non-streaming example

curl -sS "https://51kik.com/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [{"role": "user", "content": "Summarize edge gateways in one sentence."}]
  }'

Streaming

Set "stream": true and Accept: text/event-stream. See Streaming and Streaming quickstart.

Tools example

curl -sS "https://51kik.com/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL_ID",
    "messages": [{"role": "user", "content": "What is the weather in Paris?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Get weather for a city",
        "parameters": {
          "type": "object",
          "properties": { "city": { "type": "string" } },
          "required": ["city"]
        }
      }
    }],
    "tool_choice": "auto"
  }'

After tool_calls, append the assistant message with calls, then role: "tool" results, and call again.

Multimodal (file_id)

FILE_ID=$(curl -sS "https://51kik.com/v1/files" \
  -H "Authorization: Bearer $API_KEY" \
  -F purpose=assistants -F file=@./spec.pdf | jq -r .id)

curl -sS "https://51kik.com/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"model\": \"YOUR_MODEL_ID\",
    \"messages\": [{
      \"role\": \"user\",
      \"content\": [
        { \"type\": \"text\", \"text\": \"List key requirements\" },
        { \"type\": \"input_file\", \"file_id\": \"$FILE_ID\" }
      ]
    }]
  }"

See Files and context.

Response (non-streaming)

OpenAI-shaped chat.completion with choices[].message, usage, and id.

Errors

{
  "error": {
    "message": "...",
    "type": "invalid_request_error",
    "param": "messages[0].content",
    "code": null
  }
}
StatusTypical cause
400Validation (messages, parts, size)
401Invalid or expired API key
403Model denied, balance, IP, upstream keys
429Rate limit
502/503Upstream failure

See Errors · OpenAI differences.