Ollama-compatible chat. Same request/response shape as Ollama /api/chat . The response arrives in the same HTTP request.
Endpoint
POST https://llm.dat.ai/api/chat
Authorization: Bearer YOUR_API_KEY
Content-Type: application/jsonRequest body
Uses the Ollama chat schema . Full request — see Example below.
| Field | Required | Description |
|---|---|---|
model | Yes | Model name, e.g. qwen3:1.7b |
messages | Yes | Chat history — see messages below |
stream | No | Default false if omitted. Set true for streaming |
tools | No | Ollama function calling — passed through; not the same as datai.tools |
datai | No | dat.ai built-in node tools (net, fs) — see Inference overview |
messages
Array of objects with role and content:
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello!" }
]Roles: user, assistant, system (same as Ollama /api/chat ).
Other Ollama /api/chat fields (options, etc.) are passed through as-is.
Optional header: X-Request-ID.
Response
Non-streaming (200): Ollama ChatResponse with the final message in message.content and "done": true.
Streaming: Content-Type: application/x-ndjson — one JSON object per line, each with partial message.content, ending with a final object where "done": true.
Errors
Plain JSON { "error": "..." } — see Authentication. Common cases:
| Status | Cause |
|---|---|
| 400 | Invalid JSON, missing model, datai.tools + stream: true |
| 401 | Missing or invalid API key |
| 402 | Insufficient credits |
| 504 | Request timed out (max wait 180 seconds) |
Example
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
}'