API reference
Chat completions
POST /v1/chat/completions creates a model answer for a conversation, in the OpenAI format.
POST https://api.deepflock.dev/v1/chat/completionsSends a conversation to a model and returns its answer, either all at once or streamed word by word. The format follows OpenAI's Chat Completions API, so OpenAI SDKs work unchanged.
Authentication
Needs a key: Authorization: Bearer df-.... See Authentication and keys.
Request
Send JSON with Content-Type: application/json.
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | A model id, for example qwen3-235b-a22b. See Models. |
messages | array | Yes | The conversation so far. Each item has a role (system, user or assistant) and a content string. |
stream | boolean | No | true sends the answer in pieces as it is written. Default false. |
max_tokens | integer | No | The longest answer you allow, in tokens. Also sets how much credit is reserved; see Pricing. |
temperature | number | No | Randomness, from 0 to 2. 0 always picks the most likely next word. |
top_p | number | No | Only sample from the most likely words whose chances add up to this share. |
stop | string or array | No | Up to 4 strings. The answer ends before any of them. |
seed | integer | No | Makes sampling repeatable when temperature is above 0. |
stream_options | object | No | {"include_usage": true} adds a final chunk with usage to a stream. |
Only n: 1 is supported. Tool calls (tools) are rejected with 400 and the code unsupported_parameter; other unknown fields are ignored.
Exact output at temperature 0
With temperature: 0 a flock returns the same text as the same model on a single machine using the same number format. Splitting the model and our acceleration do not change the result. See Why output is exact.
Response
Without streaming you get one JSON object:
{
"id": "chatcmpl-8f2c1e",
"object": "chat.completion",
"created": 1796083200,
"model": "qwen3-235b-a22b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A heat pump moves heat instead of making it..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 41,
"total_tokens": 59
}
}| Field | Meaning |
|---|---|
choices[0].message.content | The answer text. |
choices[0].finish_reason | stop (the model finished or hit a stop string) or length (it hit max_tokens). |
usage | Tokens used. This is what you are billed for. |
Streaming
With "stream": true the response is a stream of server-sent events. Each line starts with data: and holds one JSON chunk. The stream ends with data: [DONE].
data: {"id":"chatcmpl-8f2c1e","object":"chat.completion.chunk","model":"qwen3-235b-a22b","choices":[{"index":0,"delta":{"role":"assistant","content":"A heat"},"finish_reason":null}]}
data: {"id":"chatcmpl-8f2c1e","object":"chat.completion.chunk","model":"qwen3-235b-a22b","choices":[{"index":0,"delta":{"content":" pump moves"},"finish_reason":null}]}
data: {"id":"chatcmpl-8f2c1e","object":"chat.completion.chunk","model":"qwen3-235b-a22b","choices":[{"index":0,"delta":{},"finish_reason":"stop"}],"usage":{"prompt_tokens":18,"completion_tokens":41,"total_tokens":59}}
data: [DONE]Text may arrive in small bursts of a few words rather than one word at a time.
Examples
curl
curl https://api.deepflock.dev/v1/chat/completions \
-H "Authorization: Bearer $DEEPFLOCK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3-235b-a22b",
"messages": [
{"role": "system", "content": "Answer in plain English."},
{"role": "user", "content": "What is a heat pump?"}
],
"max_tokens": 300,
"temperature": 0
}'Python
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.deepflock.dev/v1",
api_key=os.environ["DEEPFLOCK_API_KEY"])
reply = client.chat.completions.create(
model="qwen3-235b-a22b",
messages=[{"role": "user", "content": "What is a heat pump?"}],
max_tokens=300,
temperature=0,
)
print(reply.choices[0].message.content)
print(reply.usage.total_tokens, "tokens")Node
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.deepflock.dev/v1",
apiKey: process.env.DEEPFLOCK_API_KEY,
});
const reply = await client.chat.completions.create({
model: "qwen3-235b-a22b",
messages: [{ role: "user", content: "What is a heat pump?" }],
max_tokens: 300,
temperature: 0,
});
console.log(reply.choices[0].message.content);Errors
| Status | Type | When |
|---|---|---|
400 | invalid_request_error | Bad JSON, missing messages, an unsupported field, or a prompt over the context length (context_length_exceeded). |
401 | authentication_error | Missing or wrong key (invalid_api_key). |
402 | insufficient_quota | Your credit cannot cover the reservation (insufficient_funds), or the key hit its spending limit (key_limit). |
403 | permission_error | The key may not use this model (model_not_allowed). |
404 | invalid_request_error | Unknown model id (model_not_found). |
429 | rate_limit_error | Too many requests for this key (rate_limit_exceeded). See Retry-After. |
502 | server_error | The flock failed and no other flock could take over (flock_failed). |
503 | server_error | No free flock for this model right now (no_capacity). See Retry-After. |
Full details in Errors and limits.