Platform notice: all DeepSeek models are now live. New users receive trial credits on sign-up.
Api reference

Chat Completions

An OpenAI-compatible chat completion endpoint, including request parameters, billing rules, and error reference.

Request

POST /api/gateway/v1/chat/completions
  • Authentication: request header Authorization: Bearer sk-tp-... (create an API Key in the Console)
  • Content-Type: application/json

Request body

ParameterTypeRequiredDescription
modelstringYesPlatform model name; see Model list or Models
messagesarrayYesAn OpenAI-format message array; must not be empty
streambooleanNoWhen true, returns an SSE stream; see Advanced usage
Other parameters-Notemperature, top_p, max_tokens, tools, response_format, and others are passed through per the OpenAI protocol; whether they take effect depends on the model called

Response

Non-streaming responses return OpenAI ChatCompletion JSON (choices + usage). The response headers carry billing information for this call:

HeaderDescription
X-Cost-YuanCost of this call (yuan, 6 decimal places)
X-Usage-TokensTotal tokens for this call

Streaming (stream=true) returns SSE with the same event format as OpenAI, ending with data: [DONE]. The platform automatically injects stream_options.include_usage, so the final chunk carries usage. Streaming response headers don't include X-Cost-Yuan; calculate the cost from usage yourself or check the billing ledger.

Billing

  • Settled by the usage returned by the model, in "yuan per million tokens", with input and output priced separately. See Billing.
  • Cached-hit / cache-write tokens in usage.prompt_tokens_details are priced separately at the cache price; if a model has no cache price configured, the input price applies.
  • Costs are deducted from the account balance; every quota-limited key node along the request chain accumulates its subtree consumption.

Pre-checks

Before the call, the platform validates in order; if any step fails, an error is returned:

  1. Key valid and not revoked (including all parents), account status normal → otherwise 401
  2. Model exists and is available (LIVE) and is token-billed → otherwise 400
  3. messages is not empty → otherwise 400
  4. Account balance greater than 0, key chain quota not exhausted → otherwise 402

Errors

For the error response body format and troubleshooting, see FAQ · Error codes. Errors returned by the upstream model service are passed through verbatim (status code and response body unchanged).

On this page