Chat Completions
The exact stable request contract for POST /v1/chat/completions.
Endpoint
Send authenticated JSON requests to POST /v1/chat/completions. Non-streaming responses use chat.completion; streaming responses use Server-Sent Events.
Examples
1curl https://qufas-ai.vercel.app/v1/chat/completions \2 -H "Authorization: Bearer $QUFAS_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{5 "model": "kimi-k2.7-code",6 "messages": [{"role": "user", "content": "Hello"}]7 }'Supported parameters
| Parameter | Type | Required | Contract |
|---|---|---|---|
| model | string | Required | Non-empty callable model ID. |
| messages | array | Required | Non-empty system, user, assistant, or tool message array. |
| stream | boolean | Optional | Return text/event-stream when true. |
| temperature | number | null | Optional | Range [0, 2). |
| max_tokens | integer | null | Optional | Positive integer. |
| top_p | number | null | Optional | Range (0, 1]. |
| stop | string | string[] | null | Optional | One non-empty string or 1–4 non-empty strings. |
| presence_penalty | number | null | Optional | Range [-2, 2]. |
| tools | array | Optional | Function tool definitions. |
| tool_choice | string | object | Optional | auto, none, or a declared named function. |
| parallel_tool_calls | boolean | Optional | Requires at least one tool when true. |
| response_format | object | Optional | text, json_object, or json_schema. |
| seed | integer | null | Optional | Range 0–2147483647. |
| stream_options | object | null | Optional | Only with stream=true; supports include_usage. |
Messages
Supported roles are system, user, assistant, and tool. User content can be text or text/image parts. Vision input works only where the selected model supports it. Assistant tool calls and matching tool results are supported.
1[2 {3 "role": "system",4 "content": "You are concise."5 },6 {7 "role": "user",8 "content": [9 {10 "type": "text",11 "text": "Describe this image."12 },13 {14 "type": "image_url",15 "image_url": {16 "url": "https://example.com/image.png",17 "detail": "auto"18 }19 }20 ]21 },22 {23 "role": "assistant",24 "content": null,25 "tool_calls": [26 {27 "id": "call_123",28 "type": "function",29 "function": {30 "name": "lookup",31 "arguments": "{\"id\":\"123\"}"32 }33 }34 ]35 },36 {37 "role": "tool",38 "tool_call_id": "call_123",39 "content": "{\"status\":\"ok\"}"40 }41]Unsupported parameters fail explicitly
Qufas does not silently ignore unsupported public parameters. The following are not part of the stable contract: max_completion_tokens, frequency_penalty, user, n, logprobs, top_logprobs, reasoning, reasoning_effort.
Sending n: 2, for example, returns HTTP 400:
1{2 "error": {3 "message": "The parameter 'n' is not supported by this gateway.",4 "type": "invalid_request_error",5 "param": "n",6 "code": "unsupported_parameter"7 }8}Qufas prefers explicit errors over silently ignoring unsupported parameters.
OpenAI compatibility scope
Qufas supports the OpenAI Chat Completions interface for the parameter set documented on this page. It is not 100% compatibility with every OpenAI API. See the migration guide before moving existing production traffic.
Aborting a client stream stops receipt of output, but does not guarantee upstream generation cancellation. Usage can accrue after Stop and be included in the final, idempotent settlement. See streaming termination and billing semantics; a terminal [DONE] marker is not by itself a success or billing receipt.
Was this page helpful?
