Skip to content

DeepSeek Completions

Generate text with the OpenAI Legacy Completions–compatible format for DeepSeek.

http
POST /v1/completions

Legacy Completions takes a as input. It suits workloads that still use older OpenAI-compatible SDKs or simple text completion. For new chat scenarios, prefer DeepSeek Chat Completions.

The default example model is .

Available models

ModelDescription
Next-generation fast model

Headers

NameTypeRequiredDescription
stringYesRequest authentication. Use a Bearer token, for example:
stringYesRequest content type; must be

Request body

NameTypeRequiredDescription
stringYesModel ID; default example . See Available models above
string | arrayYesInput prompt. May be a string, string array, token array, or array of token arrays; official default generates from the document start marker
stringNoText that appears after the completion insert point; only supported by
integerNoMaximum tokens to generate; official default ; prompt tokens plus this value must not exceed the model context length
numberNoSampling temperature, range , default ; usually tune either or
numberNoNucleus sampling, range , default
integerNoHow many completions to generate per prompt, range , default
booleanNoWhether to stream the response, default ; when enabled, pushes SSE and ends with
objectNoStreaming options; only effective when
integerNoNumber of most likely token log probabilities to return, maximum
booleanNoWhether to echo the prompt in addition to the completion, default
string | arrayNoUp to 4 stop sequences; generation stops when encountered
numberNoRange , default
numberNoRange , default
integerNoServer generates multiple candidates and returns the best one, default , maximum ; cannot be used with streaming; when used with , must be greater than
objectNoBias map for token appearance probabilities; keys are token IDs, values
integerNoRandom seed; best-effort deterministic sampling
stringNoUnique end-user identifier for abuse monitoring

stream_options

NameTypeRequiredDescription
booleanNoPush an extra chunk containing before

Request example

bash
curl -X POST https://octopusx.ai/v1/completions \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-flash",
    "prompt": "Rewrite the following sentence more formally: This API is pretty easy to use.",
    "max_tokens": 120,
    "temperature": 0.3
  }'
bash
curl -X POST https://octopusx.ai/v1/completions \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-flash",
    "prompt": "Introduce the Completions endpoint in one sentence.",
    "max_tokens": 64,
    "stream": true,
    "stream_options": {
      "include_usage": true
    }
  }'

Response example

Non-streaming success

json
{
  "id": "cmpl_abc123",
  "object": "text_completion",
  "created": 1735689600,
  "model": "deepseek-v4-flash",
  "choices": [
    {
      "index": 0,
      "text": "This API offers good usability.",
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 22,
    "completion_tokens": 10,
    "total_tokens": 32
  }
}

Streaming chunks (illustrative)

text
data: {"id":"cmpl_abc123","object":"text_completion","choices":[{"index":0,"text":"This","finish_reason":null}]}

data: {"id":"cmpl_abc123","object":"text_completion","choices":[{"index":0,"text":" API","finish_reason":null}]}

data: [DONE]

Response fields

NameTypeDescription
stringCompletion response ID
stringObject type; always
integerResponse creation timestamp (Unix seconds)
stringModel that generated the response
arrayArray of candidate results
integerCandidate index
stringText generated by the model
stringFinish reason, e.g.
objectToken usage statistics
integerInput token count
integerOutput token count
integerTotal token count