文档中心/API 参考/对话补全接口

对话补全接口

对话补全接口是 AItiktak 最核心的 API,用于与大模型进行多轮对话交互。

POST/v1/chat/completionsstable

请求参数

参数类型必填说明
modelstring模型名称,如 qwen-plusdoubao-pro
messagesarray对话消息列表,每个消息包含 rolecontent
temperaturenumber随机性控制,范围 0-2,默认 1。值越高输出越随机
max_tokensinteger最大生成 token 数,默认 1024
streamboolean是否启用流式输出,默认 false
providerstring指定服务商,如 alivolctencent
top_pnumber核采样参数,范围 0-1,默认 1
frequency_penaltynumber频率惩罚,范围 -2 到 2,默认 0
presence_penaltynumber存在惩罚,范围 -2 到 2,默认 0
stoparray停止词数组,最多 4 个

响应格式

{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "qwen-plus",
  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "你好!有什么可以帮助你的?"
    },
    "finish_reason": "stop" | "length" | "tool_calls"
  }],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 20,
    "total_tokens": 30
  }
}