Skip to Content

OpenAI-compatible chat. The response arrives in the same HTTP request.

Endpoint

POST https://llm.dat.ai/v1/chat/completions Authorization: Bearer YOUR_API_KEY Content-Type: application/json

Request body

JSON object. For the full shape — including messages — see the example below.

FieldRequiredDescription
modelYesModel name, e.g. qwen3:1.7b
messagesYesObjects with role and content (roles: user, assistant, system)
streamNoDefault false. Set true for SSE streaming
max_tokens, max_completion_tokensNoMax tokens to generate
temperature, top_p, stop, seedNoStandard OpenAI sampling options
tools, tool_choiceNoOpenAI function calling — see Function calling below
dataiNodat.ai built-in node tools — see Inference overview

Optional header: X-Request-ID (correlation ID; server generates a UUID if omitted).

Function calling

Use tools and tool_choice for OpenAI function calling : declare functions the model can call, and optionally control selection with tool_choice (auto, none, required, or a specific function).

  • tools — array of { "type": "function", "function": { "name", "description", "parameters" } } where parameters is a JSON Schema object
  • tool_choice — whether/how the model picks a tool

These fields are forwarded to the node unchanged. They are not the same as datai.tools (net, fs), which turn on dat.ai built-in node capabilities.

Response

Non-streaming (200): standard OpenAI chat.completion:

{ "id": "chatcmpl-...", "object": "chat.completion", "model": "qwen3:1.7b", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello!" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 5, "total_tokens": 15 } }

usage is present only when the node reports token counts.

Streaming: Content-Type: text/event-stream. Chunks follow the OpenAI streaming format; the stream ends with data: [DONE].

Errors

OpenAI-style JSON — see Authentication. Common cases:

StatusCause
400Invalid JSON, missing model/messages, datai.tools + stream: true
401Missing or invalid API key
402Insufficient credits
504Request timed out (max wait 180 seconds)

Example

curl -sS -X POST "https://llm.dat.ai/v1/chat/completions" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen3:1.7b", "messages": [{"role": "user", "content": "Hello!"}], "stream": false }'