😀 Chat 对话
http
WEBSOCKET wss://api.chatnio.net/chat
说明
在开始对话前, 需要先发送鉴权参数结构, 之后即可发送对话参数结构, 并接收流式输出的响应参数。
鉴权参数
Name | Type | Description |
---|---|---|
token* | String | API Key |
id* | String | 对话 ID (新对话时为 -1) |
对话参数
Name | Type | Description |
---|---|---|
message* | String | 消息 |
model* | String | 模型 |
web | String | 是否开启联网(默认关闭) |
type | String | chat 对话 / stop 暂停输出 / restart 重新回答 |
流响应结构
json
{
"message": " how", // chunk message
"quota": 0.02, // quota usage
"end": false // output status
}
连接示例
json
WEBSOCKET wss://api.chatnio.net/chat
> SEND {"token":"sk-...","id":-1}
> SEND {"type": "chat", "message": "hi", "web": false, "model": "gpt-4", "ignore_context": false}
< RECV {"quota": 0, "keyword": "", "message": "Hello", "end": false}
< RECV {"quota": 0.0034000003, "keyword": "", "message": "!", "end": false}
< RECV {"quota": 0.0034000003, "keyword": "", "message": "", "end": true}