/v1/chat/completionsChat Completions API
Creates a chat completion response. The endpoint is fully compatible with the OpenAI Chat Completions format and can be used directly with the official OpenAI SDKs (Python / Node.js) — just change base_url and api_key. Supports streaming, multi-turn conversations, function calling, vision, and more.
/v1/chat/completions supports all models available on NexusFlow — including Qwen, GLM, DeepSeek, Kimi, MiniMax, and more.Request Endpoint
https://nexusflow.hk/v1/chat/completionsRequest Headers
Request Parameters
Code Examples
Response Format (Non-streaming)
Non-streaming requests return a complete JSON object whose object field is "chat.completion".
Response Example
Response Fields
Streaming Response Format (SSE)
When stream: true, the response is returned incrementally as Server-Sent Events (SSE). Each event starts with data: and the stream ends with data: [DONE]. Each chunk's object field is "chat.completion.chunk".
SSE Data Format
Chunk Fields
Protocol Pass-through
/v1/chat/completions is fully pass-through with the OpenAI Chat Completions protocol: the request body is forwarded to the upstream as-is, and the response is returned as-is. Extension fields such as tools, tool_choice, response_format,enable_thinking, thinking_budget, enable_search, search_options,seed, top_k, logprobs, and stream_options can be used directly. Actual support depends on the model.Billing
Tiered Pricing
Model families such as Qwen and GLM use tiered pricing based on the request's input token count. The total prompt tokens of a single request determine the applicable price tier, and input and output are billed at that tier's unit prices respectively.
For example, a request with 50K input tokens + 2K output tokens is billed at $4/M for input and $16/M for output (Tier 2). See the full tiered pricing on the Pricing page.
Context Cache (Prompt Caching)
Context caching is supported when calling via /v1/messages (Anthropic protocol). For repeated system prompts or long documents, the upstream automatically caches the prompt prefix, and subsequent requests get a discount on the cached portion:
/v1/chat/completions supports explicit caching via the enable_context_caching: true parameter. /v1/messages (Anthropic protocol) supports the cache_control content block annotation. Both protocols automatically benefit from implicit cache discounts.
Notes
- The
max_tokenslimit varies by model; see the Models list for each model's limits. - Adjust only one of
temperatureortop_p; setting both may produce unpredictable results. - In streaming output, only the final chunk's
finish_reasonis non-null, marking the end of generation. - For image understanding, use multimodal models such as the Qwen-VL series.
contentmust be an array that includes animage_urltype. - For function calling, use model families that support tools, such as Qwen, DeepSeek, and GLM.
- Thinking mode (
enable_thinking) must be used per model ID; see the support matrix in the Parameter Matrix. - The request body is passed through to the upstream protocol; extension fields beyond this doc (such as
thinking_budget,enable_search,search_options) can be used directly, with actual support depending on the model. - For the full parameter reference and model compatibility matrix, see the Parameter Matrix.