Protocol endpoints
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
| Purpose | Method and path |
|---|---|
| Model request | POST /v1/chat/completions |
| Compatible path | POST /chat/completions |
| Model list | GET /v1/models, GET /v1/models/, GET /models, GET /models/ |
Request example
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
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 requires upstream usage data for a streaming Chat Completions request so the completed call can be settled.
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.
Missing usage fails the request
DINGJIAI needs explicit usage data for settlement. If an upstream returns content without usage, the call is handled as usage_missing or usage_invalid.
Last updated on