Docs
API Reference

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

ParameterTypeRequiredContract
modelstringRequiredNon-empty callable model ID.
messagesarrayRequiredNon-empty system, user, assistant, or tool message array.
streambooleanOptionalReturn text/event-stream when true.
temperaturenumber | nullOptionalRange [0, 2).
max_tokensinteger | nullOptionalPositive integer.
top_pnumber | nullOptionalRange (0, 1].
stopstring | string[] | nullOptionalOne non-empty string or 1–4 non-empty strings.
presence_penaltynumber | nullOptionalRange [-2, 2].
toolsarrayOptionalFunction tool definitions.
tool_choicestring | objectOptionalauto, none, or a declared named function.
parallel_tool_callsbooleanOptionalRequires at least one tool when true.
response_formatobjectOptionaltext, json_object, or json_schema.
seedinteger | nullOptionalRange 0–2147483647.
stream_optionsobject | nullOptionalOnly 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.

Supported message shapes
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:

400 JSON
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?