ChatGPT

示例中的 _id 需要替换成你自己的
示例中的 hmp_... 需要替换为自己的令牌 获取令牌

POST /v1/openai/chatcmpl

将一系列消息作为输入,并返回模型生成的消息作为输出,可以实现诸如:

  • 聊天机器人
  • 起草书面文件
  • 翻译
  • 文本润色
  • 文本总结

每次成功请求消耗 3 金币(如有变动以实际为准)

参数

名称类型描述
messages[object]对象参见 message,最大数量 20

message

名称类型描述
rolestring可选值:
  • user
  • system
  • assistant
contentstring内容,最大长度 1000 个字符

示例

Hamibot 示例

// _id 和 hmp_... 需要替换成自己的
http.request('https://api.hamibot.com/v1/openai/chatcmpl', {
  method: 'POST',
  contentType: 'application/json',
  headers: {
    authorization: 'hmp_...',
  },
  body: JSON.stringify({ messages: [{ role: 'user', content: '你好' }] }),
});

curl 示例

curl \
    -X POST \
    -H "Authorization: hmp_..." \
    -H "Content-Type: application/json" \
    -d '{"messages": [{"role": "user", "content": "你好"}]}' \
    https://api.hamibot.com/v1/openai/chatcmpl

响应

200 成功

{
  "role": "assistant",
  "content": "回复内容"
}

422 参数错误

400 金币余额不足