Notice: MAI Image 2.7 launch limited-time 20% off, covering the full text-to-image and image editing lineup, try it now
Notice: Black Friday 2026 × Cyber Monday: Get up to 30% extra on top-ups, DeepSeek free to use · View the promotion
Open navigation

Chat Completions API

Endpoint: 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].

Authentication

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.

Request

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.

Response and usage

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.

Streaming

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.

Errors

  • 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 Claude Sonnet 4.6, Kimi K3, and DeepSeek V4 Flash for model-specific fields and live pricing for current Token rates.

See DeepSeek V4.1 Flash for its Responses and Chat Completions contract, with low/high/max Chat reasoning and stateless Responses conversations.