Skip to content
English

Chat Completions API

POST /v1/chat/completions

Use the Chat Completions endpoint for text models. A non-streaming request returns one JSON response; stream: true returns Server-Sent Events ending with [DONE].

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

The same HiAPI API key can call every model enabled for your account. Text models use /v1/chat/completions; image, video, and audio models use /v1/tasks with an input object and asynchronous task lifecycle.

Terminal window
curl https://api.hiapi.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Explain sparse attention."}],
"stream": false
}'

Required fields are model and messages. Common optional fields include stream, max_tokens, thinking, reasoning_effort, response_format, and tools; support can vary by model.

Read the final answer from choices[0].message.content. Thinking models can also return choices[0].message.reasoning_content. The usage object reports prompt, completion, cached-input, and total Token counts used for billing.

Set stream: true, parse each data: event as JSON, and stop after data: [DONE]. Accumulate choices[0].delta.content; thinking models can emit choices[0].delta.reasoning_content.

  • 401: missing or invalid API key.
  • 402: insufficient balance.
  • 400: unsupported model or invalid parameter.
  • 429: rate limit reached.
  • 503: model temporarily unavailable; retry with bounded exponential backoff.

See DeepSeek V4 Flash for model-specific fields and live pricing for current Token rates.