API文档

请求说明

基本信息

调用本接口,发起一次对话请求。

注意事项

本文接口返回不支持图片内容,图片内容的请求返回会在后续支持,敬请期待!

请求地址:

https://brain-llm-saas.emotibot.com/api/v1/model/chat_completions_stream_endpoint?apiKey={key}

请求方式: POST

Header参数

名称
Content-Typeapplication/json

Query参数

名称类型必填描述
apiKeyString通过apiKey鉴权后调用接口

Body参数

名称类型必填描述
model_uidString模型对应的uuid
runtime_parametersruntime_parameters模型生成参数

runtime_parameters说明

名称类型描述
max_tokensInteger生成结果最长字符限制
top_pFloat指模型对输出每个词过滤的概率分值
temperatureFloat生成温度,用于控制生成文本的多样性和创造力。数值越低表示越低的随机性。一般来说,temperature越低,适合完成确定性的任务。temperature越高,适合完成创造性的任务。
top_kInteger生成采样的最大前n个token
repetition_penaltyFloat重复惩罚,用于控制生成文本中的重复程度。
messagesmessage[]对话信息

message说明

名称类型描述
roleString角色,user: 表示用户assistant: 表示对话助手
contentString对话内容,不能为空

响应说明

名称类型描述
codeInteger响应码,成功返回200
messageString响应描述,成功返回success
datadata[]响应返回数据

data说明

名称类型描述
deltadelta返回的content内容
logprobsStringNone
indexInteger位置信息
finish_reasonString结束原因

delta说明

名称类型描述
contentString文本内容

请求示例

请求格式

curl --location 'https://brain-llm-saas.emotibot.com/api/v1/model/chat_completions_stream_endpoint?apiKey={key}' \
--header 'Content-Type: application/json' \
--data '{
  "model_uid": "DokGt2E3jLrFWhyOsTcmKCif4RIu790glYanNVzpxSqdevPwbX",
  "runtime_parameters": {
    "temperature": 0.2,
    "max_tokens": 200,
    "top_k": 10,
    "top_p": 0.85,
    "repetition_penalty": 1.2,
    "messages": [{
      "role": "user",
      "content": "你好,北京什么气候"
    },
    {
      "role": "assistant",
      "content": "北京是亚热带气候。"
    },
    {
      "role": "user",
      "content": "那上海呢?"
    }]
  }
}'

响应示例

{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": ""}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "上"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "海"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "属"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "于"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "亚"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "热"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "带"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "海"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "洋"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "性"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "气"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "候"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": "。"}, "logprobs": null, "index": 0, "finish_reason": null}]
}
{
  "code": 200,
  "message": "success",
  "data": [{"delta": {"content": ""}, "logprobs": null, "index": 0, "finish_reason": null}]
}

错误码

错误码错误信息描述
200success接口调用成功
401invalid api keyapiKey非法