DINGJIAI
DINGJIAI
Quick start in 5 minutesWhat is DINGJIAI?

Popular Agents

Codex SetupClaude Code SetupOne-Click Setup

API Reference

ResponsesChat Completions

Billing

Model pricing
API families and API entries

Chat Completions

The OpenAI-compatible Chat Completions endpoint.

OpenAI-compatible endpoint

Chat Completions is suitable for existing OpenAI-compatible clients. It uses a Bearer user API Key and settles charges from the OpenAI usage fields.

Paths

PurposeMethod and path
Model requestPOST /v1/chat/completions
Compatible pathPOST /chat/completions
Model listGET /v1/models, GET /v1/models/, GET /models, GET /models/

Request example

POST /v1/chat/completions
curl https://dingjiai.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_USER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "A_MODEL_NAME_COPIED_FROM_THE_OPENAI_CHAT_MODEL_LIST",
    "messages": [
      { "role": "user", "content": "Introduce yourself in one sentence" }
    ]
  }'

Streaming

stream=true
curl -N https://dingjiai.com/v1/chat/completions \
  -H "Authorization: Bearer YOUR_USER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "A_MODEL_NAME_COPIED_FROM_THE_OPENAI_CHAT_MODEL_LIST",
    "stream": true,
    "messages": [
      { "role": "user", "content": "Explain the integration in three points" }
    ]
  }'

The gateway prefers upstream stream usage. If at least one upstream/model chunk has been delivered but final usage is missing or invalid, a token-priced product may settle with a conservative lower-bound estimate. A disconnect or client cancellation after delivery follows the same partial-usage/output-floor rule. A truly blank or malformed non-stream response has not been committed to the client, so it fails for the client as usage_missing or usage_invalid, releases the reservation, and is charged zero.

For a stream, the gateway commits the response headers after the upstream returns 2xx. If the stream ends without delivering an upstream/model chunk, the client still receives a 2xx response; its body may be empty or contain only gateway-generated SSE keepalives. The gateway cannot rewrite that response as an error. It releases the reservation, charges zero, and records the settlement failure and call observation. This is a different client-visible result from a blank or malformed non-stream response.

Request fields

Prop

Type

Usage and billing

Settlement reads usage.prompt_tokens, usage.completion_tokens, and the optional usage.prompt_tokens_details.cached_tokens field from the response body.

Upstream explicit usage data remains the preferred and most accurate settlement source.

Real usage takes priority

The server never trusts client-supplied token estimates. For token-priced products, a valid JSON object or a stream that delivered at least one upstream/model chunk may use a conservative lower-bound estimate when usage is missing or invalid. Truly blank or malformed non-stream bodies fail closed for the client as usage_missing or usage_invalid and are charged zero. A stream with zero upstream/model chunks has already committed a 2xx response whose body may be empty or contain only gateway-generated SSE keepalives, so the gateway records the failure, releases the reservation, and charges zero instead of returning an error body.

Last updated on

ResponsesCodex Search capability

On this page

PathsRequest exampleStreamingRequest fieldsUsage and billing