Volcengine
Authentication
Volcengine Chat
接口功能:Volcengine Chat
Method & Path
-
POST {domain}/bp/ai/volcengine/chat
-
POST {domain}/bp/server/user/{user_id}/ai/volcengine/chat
Request
- content-type: "application/json"
Parameters | Type | Required | Desc |
---|---|---|---|
strategy | string | true | strategy |
response_format | string | false | 返回格式,如果需要返回 json 则为 json_object |
chat_id | string | false | 如果在 console 配置保存历史记录则请求服务端会返回,后续可带上 |
messages | []object | true | 详细格式如下 |
tools | object | false | 函数调用 |
json
{
"strategy": "volcengine",
"messages": [
{
"content": "hi",
"role": "user"
}
]
}
Response
- HTTP 状态码:200
json
{
"asset": [
{
"last_recovery_time": "2024-07-05T00:00:00Z",
"name": "ai_credit",
"quantity": 50,
"recoverable": true,
"recovery_period": 1,
"recovery_quantity": 50,
"type": "consumable",
"valid_seconds": 0
}
],
"chat_id": "CtESPJTMUWJ2R6RDSW",
"current_count": 7,
"current_total_count": 56,
// 以上为 BP 返回数据
// 以下为 volcengine 平台返回数据
"id": "e415023d-4f3a-4155-8fbf-5f82afb228ff",
"object": "chat.completion",
"created": 1722505362,
"model": "doubao-pro-32k-240615",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! It's nice to meet you. Is there something I can help you with or would you like to chat?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"total_tokens": 37,
"completion_tokens": 25
}
}
- HTTP 状态码:4xx
json
{
"error": {
"error_type": "invalid_parameter",
"message": "xxxxx"
}
}
error_type:
- item_not_found(找不到条目)
- config_invalid (console 配置问题)
Volcengine Chat Stream
接口功能:Volcengine Chat Stream
Method & Path
-
POST {domain}/bp/ai/volcengine/chat/stream
-
POST {domain}/bp/server/user/{user_id}/ai/volcengine/chat/stream
Request
- content-type: "application/json"
Parameters | Type | Required | Desc |
---|---|---|---|
strategy | string | true | strategy |
response_format | string | false | 返回格式,如果需要返回 json 则为 json_object |
chat_id | string | false | 如果在 console 配置保存历史记录则请求服务端会返回,后续可带上 |
messages | []object | true | 详细格式如下 |
tools | object | false | 函数调用 |
json
{
"strategy": "volcengine",
"messages": [
{
"content": "hi",
"role": "user"
}
]
}
Response
- HTTP 状态码:200
json
data: {"id":"d8acab24-95a8-4de9-bfa2-4485233b7e47","object":"chat.completion.chunk","created":1723016524,"model":"accounts/volcengine/models/llama-v3p1-405b-instruct","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null,"content_filter_results":{"hate":{"filtered":false},"self_harm":{"filtered":false},"sexual":{"filtered":false},"violence":{"filtered":false}}}],"system_fingerprint":""}
data: {"id":"d8acab24-95a8-4de9-bfa2-4485233b7e47","object":"chat.completion.chunk","created":1723016524,"model":"accounts/volcengine/models/llama-v3p1-405b-instruct","choices":[{"index":0,"delta":{"content":"Hi!"},"finish_reason":null,"content_filter_results":{"hate":{"filtered":false},"self_harm":{"filtered":false},"sexual":{"filtered":false},"violence":{"filtered":false}}}],"system_fingerprint":""}
data: {"id":"d8acab24-95a8-4de9-bfa2-4485233b7e47","object":"chat.completion.chunk","created":1723016524,"model":"accounts/volcengine/models/llama-v3p1-405b-instruct","choices":[{"index":0,"delta":{"content":" How are you"},"finish_reason":null,"content_filter_results":{"hate":{"filtered":false},"self_harm":{"filtered":false},"sexual":{"filtered":false},"violence":{"filtered":false}}}],"system_fingerprint":""}
data: {"id":"d8acab24-95a8-4de9-bfa2-4485233b7e47","object":"chat.completion.chunk","created":1723016524,"model":"accounts/volcengine/models/llama-v3p1-405b-instruct","choices":[{"index":0,"delta":{"content":" today? 😊"},"finish_reason":null,"content_filter_results":{"hate":{"filtered":false},"self_harm":{"filtered":false},"sexual":{"filtered":false},"violence":{"filtered":false}}}],"system_fingerprint":""}
data: {"id":"d8acab24-95a8-4de9-bfa2-4485233b7e47","object":"chat.completion.chunk","created":1723016524,"model":"accounts/volcengine/models/llama-v3p1-405b-instruct","choices":[{"index":0,"delta":{},"finish_reason":"stop","content_filter_results":{"hate":{"filtered":false},"self_harm":{"filtered":false},"sexual":{"filtered":false},"violence":{"filtered":false}}}],"system_fingerprint":"","usage":{"prompt_tokens":37,"completion_tokens":10,"total_tokens":47}}
data: {"chat_id":"CtEVEE5VNSPJD4S4KX"}
data: [DONE]
说明:在官方基础上新增一个 chat_id, 用于 BP 记录聊天记录
- HTTP 状态码:4xx
json
{
"error": {
"error_type": "invalid_parameter",
"message": "xxxxx"
}
}
error_type:
- item_not_found(找不到条目)
- config_invalid (console 配置问题)
Volcengine Image
接口功能:Volcengine Image
Method & Path
-
POST {domain}/bp/ai/volcengine/image
-
POST {domain}/bp/server/user/{user_id}/ai/volcengine/image
Request
- content-type: "application/json"
Parameters | Type | Required | Desc |
---|---|---|---|
strategy | string | true | strategy |
prompt | string | true | 必填 |
... | ... | false | 其它官方参数,如果不指定则为官方默认值 |
json
{
"strategy": "volcengine",
"prompt": "千军万马"
}
Response
- HTTP 状态码:200
json
{
"asset": [
{
"last_recovery_time": "2024-08-26T00:00:00Z",
"name": "ai_credit",
"quantity": 50,
"recoverable": true,
"recovery_period": 1,
"recovery_quantity": 50,
"type": "consumable",
"valid_seconds": 0
}
],
"current_count": 4,
"current_total_count": 7,
"data": [
"https://715x351k8o.debug-static.bytepowerapp.cn/ai/image_resp/2024-08-26/758932799321.png"
]
}