Chat Completions

Send a conversation, request structured output and read the model reply.

Create a chat completion

POST /v1/chat/completions. The shorter /v1/chat path accepts the same body.

JSON
{
  "model": "deepseek-v4.1-flash-1017",
  "messages": [
    {"role": "system", "content": "Answer concisely."},
    {"role": "user", "content": "How does a queue differ from a stack?"}
  ],
  "max_tokens": 256
}
Field Use
model An ID from your model catalogue.
messages Ordered conversation. Use user, assistant, system, developer and matching tool messages.
max_tokens / max_completion_tokens Positive output budget, capped at 16,384 tokens. max_completion_tokens takes precedence when supplied.
stream Use true for server-sent events.
n Generate one to five choices. Each output counts towards the account rate limit.
thinking / reasoning_effort Enable reasoning and choose a supported level where offered.
tools / tool_choice Advertise built-in or custom tools and select auto, none, required or a specific function.
response_format Request text, a JSON object or a JSON schema.
system_prompt / agents_md Custom instructions sent with the request.
store Use true to store the completion for retrieval.

Sampling options include temperature, top_p, stop, seed, frequency_penalty and presence_penalty. Support can depend on the selected model.

Read the result

JSON
{
  "object": "chat.completion",
  "model": "deepseek-v4.1-flash-1017",
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "A queue is first in, first out. A stack is last in, first out."},
      "finish_reason": "stop"
    }
  ]
}

The example omits identifiers, timestamps and usage. finish_reason can be stop, length, or tool_calls. A length result may be incomplete. Read message.tool_calls when the model asks your client to call a function.

If Site6 reports an alternate answer model after an eligible tool recovery, answer_model identifies it. tool_router_model identifies tool selection when available.

Request JSON

Ask for JSON in the message as well as setting response_format.

JSON
{
  "model": "deepseek-v4.1-flash-1017",
  "messages": [{"role": "user", "content": "Return JSON with a boolean field named ready."}],
  "max_tokens": 96,
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "ready_result",
      "strict": true,
      "schema": {
        "type": "object",
        "properties": {"ready": {"type": "boolean"}},
        "required": ["ready"],
        "additionalProperties": false
      }
    }
  }
}

Use {"type":"json_object"} for a JSON object without a specified schema. Structured output and active tools belong in separate requests.

Search the docs