Chat completions

POST https://api.fabrence.com/v1/chat/completions

Returns the model’s next message in a conversation. Requests and responses use the OpenAI Chat Completions format.

Request body

Field Type Description
model string Required. Model ID, for example moonshotai/kimi-k3.1-pro.
messages array Required. The conversation so far. Each message has a role (system, user, assistant or tool) and content.
max_tokens integer Maximum number of tokens to generate.
temperature number Sampling temperature, 0 to 2. Lower is more deterministic.
top_p number Nucleus sampling, 0 to 1.
stop string or array Up to 4 sequences where generation stops.
seed integer Makes sampling deterministic on a best-effort basis.
presence_penalty number -2 to 2.
frequency_penalty number -2 to 2.
tools array Functions the model may call. See Tool calling.
tool_choice string or object auto, none, required or a specific function.
response_format object json_object or json_schema. See Structured output.
stream boolean Return server-sent events. See Streaming.
stream_options object {"include_usage": true} adds usage to the last chunk.
reasoning object {"enabled": false} or {"effort": "none"} turns thinking off on models that think by default.
chat_template_kwargs object Passed to the model’s chat template. For example, {"enable_thinking": false} turns thinking off on Qwen models.

Response

{
  "id": "chatcmpl-8f2c1e",
  "object": "chat.completion",
  "created": 1793990400,
  "model": "moonshotai/kimi-k3.1-pro",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Hello!" },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 3,
    "total_tokens": 15,
    "prompt_tokens_details": { "cached_tokens": 0 }
  }
}

finish_reason

Value Meaning
stop The model finished, or hit a stop sequence.
length Reached max_tokens or the context limit.
tool_calls The model is calling one or more tools.