Skip to main content

Endpoint

  • POST /api/chat

What it does

Ollama-compatible chat:
  • non-streaming: a single JSON object (application/json)
  • streaming: NDJSON (application/x-ndjson, one JSON object per line)

Request body (Ollama-like)

  • model (string, required) — model name.
  • messages (array, expected) — array of {role, content} messages.
  • system (string, optional) — system prompt.
  • options (object, optional) — Ollama options (examples: temperature, top_p, top_k, num_predict, num_ctx, stop, seed).
  • stream (bool, optional) — enable streaming (defaults to false).
  • datai.tools (optional) — built-in tools switch (same as in Completions).
Minimal request:
{
  "model": "qwen3:1.7b",
  "messages": [{ "role": "user", "content": "Hello!" }],
  "stream": false
}

Response (non-streaming)

{
  "model": "qwen3:1.7b",
  "created_at": "2026-01-13T12:34:56.123456Z",
  "message": { "role": "assistant", "content": "..." },
  "done": true,
  "prompt_eval_count": 123,
  "eval_count": 456
}
Metric fields may be missing.

Streaming (NDJSON)

{"model":"qwen3:1.7b","created_at":"...","message":{"role":"assistant","content":"Hel"},"done":false}
{"model":"qwen3:1.7b","created_at":"...","message":{"role":"assistant","content":"lo"},"done":false}
{"model":"qwen3:1.7b","created_at":"...","message":{"role":"assistant","content":"Hello!"},"done":true,"prompt_eval_count":10,"eval_count":20}
Streaming errors may also be sent as NDJSON lines:
{ "error": "..." }

curl examples

Non-streaming:
curl -sS -X POST "https://llm.dat.ai/api/chat" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3:1.7b",
    "messages": [{"role":"user","content":"Hello!"}],
    "stream": false
  }'
Streaming (NDJSON):
curl -N -X POST "https://llm.dat.ai/api/chat" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3:1.7b",
    "messages": [{"role":"user","content":"Spell HELLO"}],
    "stream": true
  }'
Tools (non-streaming only):
curl -sS -X POST "https://llm.dat.ai/api/chat" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3:1.7b",
    "messages": [{"role":"user","content":"Open https://example.com and summarize the page"}],
    "stream": false,
    "datai": { "tools": { "net": true, "webview": true } }
  }'