易盾代答同步调用接口文档
接口说明
| 项目 | 说明 |
|---|---|
| 域名 | as.dun.163.com |
| 方法 | HTTPS |
| 请求 URL | /v1/proxy-answer/text/chat/completions |
| 调用方式 | 同步调用,等待模型完成执行并返回最终结果,或使用 SSE 调用 |
| 字符编码 | UTF-8 |
| 请求格式 | JSON |
| 响应格式 | JSON 或标准 Stream Event |
| 请求类型 | POST |
| 开发语言 | 任何能够发起 HTTP 请求的开发语言 |
请求
请求参数
| 参数名称 | 类型 | 必填 | 参数描述 |
|---|---|---|---|
yidun_check_uuid |
String | 是 | 易盾内容安全检测 uuid,由用户端传递,需要唯一 |
request_id |
String | 否 | 用于区分每次请求的唯一标识符。如果用户端未提供,平台将默认生成 |
stream |
Boolean | 否 | 该参数在使用同步调用时应设置为 false 或省略。表示模型在生成所有内容后一次性返回所有内容。默认值为 false。如果设置为 true,模型将通过标准 Event Stream 逐块返回生成的内容。当 Event Stream 结束时,将返回一个 data: [DONE] 消息 |
请求示例
{
"yidun_check_uuid": "yvuvkkhoigkstkros01jg02z0910ce5s",
"stream": true
}
返回
返回参数
| 参数名称 | 类型 | 参数描述 |
|---|---|---|
id |
String | 任务 ID |
created |
Long | 请求创建时间,为 Unix 时间戳,单位为秒 |
choices |
List | 当前对话的模型输出内容 |
∟ index |
Integer | 结果索引 |
∟ message |
Object | 模型返回的文本消息(同步调用) |
∟∟ role |
String | 当前对话角色,默认为 assistant(模型) |
∟∟ content |
String | 当前对话内容 |
∟ delta |
Object | 模型增量返回的文本信息(流式调用) |
∟∟ role |
String | 当前对话角色,默认为 assistant(模型) |
∟∟ content |
String | 当前对话内容 |
返回示例
非 stream 格式:
{
"id": "04ea926191a14749b7f2c7a48a68abc6",
"created": 1698999496,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": " 你好,李雷!1+1 等于 2。如果你有其他问题,请随时提问!"
}
}
]
}
stream 格式:
data: {"id":"04ea926191a14749b7f2c7a48a68abc6","created":1699005632,"choices":[{"index":0,"delta":{"role":"assistant","content":""}}]}
data: {"id":"04ea926191a14749b7f2c7a48a68abc6","created":1699005632,"choices":[{"index":0,"delta":{"content":" 你好"}}]}
...
data: {"id":"04ea926191a14749b7f2c7a48a68abc6","created":1699005632,"choices":[{"index":0,"delta":{"content":" 。"}}]}
data: {"id":"04ea926191a14749b7f2c7a48a68abc6","created":1699005632,"choices":[{"index":0,"delta":{}}]}
data: [DONE]
错误说明
错误示例
HTTP 400:
{
"error": {
"type": "invalid_request",
"message": "Invalid request, The request was rejected"
}
}
HTTP 500:
{
"error": {
"type": "server_error",
"message": "service error, please contact service manager"
}
}
错误码说明
| HTTP 错误码 | errorType | errorMessage | 错误说明 | 详细描述 |
|---|---|---|---|---|
| 400 | invalid_request |
Invalid request, The request was rejected | 模型拒答 | 指导客户侧输出相关拒答文案,接口返回"模型拒答" |
| 500 | server_error |
service error, please contact service manager | 内部错误,请联系管理员 | 指导客户侧输出相关拒答文案,接口返回"内部错误" |

