API Reference
Chat Completions API Reference
Specification for the authenticated POST /v1/chat/completions endpoint.
POST /v1/chat/completions (Authenticated Endpoint)
Generates chat completions from models, with full support for Server-Sent Events (SSE) streaming, autonomous tool calling, structured JSON output, and reasoning tokens.
Authenticated Access: This endpoint requires a valid API key with a non-zero credit balance passed via
Authorization: Bearer sk_live_....
Request Headers
| Header | Type | Required | Description |
|---|---|---|---|
Authorization | string | Yes | Bearer token format: Bearer sk_live_... |
Content-Type | string | Yes | Must be application/json |
Request Body Parameters
Parameters Reference
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model identifier (e.g. kimi-k2.7-code, glm-5.3-flash, qwen3.6-plus, deepseek-v4-flash). |
messages | array | Yes | Array of conversation messages (role: system | user | assistant | tool, content: string). |
stream | boolean | No | If true, returns Server-Sent Events (SSE). Recommended for interactive apps and coding harnesses. |
temperature | number | No | Sampling temperature between 0 and 2. Defaults to 1. |
max_tokens | integer | No | Maximum number of completion tokens to produce. |
tools | array | No | Array of OpenAI-format tool definitions for function calling. |
tool_choice | string | object | No | Controls tool selection: "none", "auto", "required", or specific function object. |
response_format | object | No | E.g. { "type": "json_object" } to force valid JSON output. |
stop | string | array | No | Up to 4 sequences where the model should stop generating. |
Response Formats
1. Streaming Response (stream: true)
Returns a continuous text/event-stream stream formatted as Server-Sent Events (SSE):
2. Deep Reasoning Models (reasoning_content)
Reasoning models stream their internal thought processes in delta.reasoning_content before emitting the final answer in delta.content:
3. Non-Streaming Response (stream: false)
Two-Phase Atomic Credit Reservations
Interference uses atomic credit reservations to prevent runaway charges and negative balances:
- Pre-flight Hold: Before initiating inference, a temporary credit hold is placed based on prompt length and estimated max output.
- Stream Execution: Tokens are streamed with zero delay.
- Post-flight Settlement: Once the stream ends (or if the user cancels with
Ctrl+C), the hold is settled for the exact number of tokens actually generated, and any unused credit hold is returned immediately to your balance.