API reference

Chat completions

POST /v1/chat/completions creates a model answer for a conversation, in the OpenAI format.

Shell
POST https://api.deepflock.dev/v1/chat/completions

Sends 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.

FieldTypeRequiredDescription
modelstringYesA model id, for example qwen3-235b-a22b. See Models.
messagesarrayYesThe conversation so far. Each item has a role (system, user or assistant) and a content string.
streambooleanNotrue sends the answer in pieces as it is written. Default false.
max_tokensintegerNoThe longest answer you allow, in tokens. Also sets how much credit is reserved; see Pricing.
temperaturenumberNoRandomness, from 0 to 2. 0 always picks the most likely next word.
top_pnumberNoOnly sample from the most likely words whose chances add up to this share.
stopstring or arrayNoUp to 4 strings. The answer ends before any of them.
seedintegerNoMakes sampling repeatable when temperature is above 0.
stream_optionsobjectNo{"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:

JSON
{
  "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
  }
}
FieldMeaning
choices[0].message.contentThe answer text.
choices[0].finish_reasonstop (the model finished or hit a stop string) or length (it hit max_tokens).
usageTokens 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].

JSON
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

Shell
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

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

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

StatusTypeWhen
400invalid_request_errorBad JSON, missing messages, an unsupported field, or a prompt over the context length (context_length_exceeded).
401authentication_errorMissing or wrong key (invalid_api_key).
402insufficient_quotaYour credit cannot cover the reservation (insufficient_funds), or the key hit its spending limit (key_limit).
403permission_errorThe key may not use this model (model_not_allowed).
404invalid_request_errorUnknown model id (model_not_found).
429rate_limit_errorToo many requests for this key (rate_limit_exceeded). See Retry-After.
502server_errorThe flock failed and no other flock could take over (flock_failed).
503server_errorNo free flock for this model right now (no_capacity). See Retry-After.

Full details in Errors and limits.

View as MarkdownUpdated 2026-12-01