對話與訊息回覆(串流/同步)
對話與同步
向 AI 助理發送訊息並取得回應。
curl -X POST \
'https://api.maiagent.ai/api/v1/chatbots/{chatbot_id}/completions/' \
-H 'Authorization: Api-Key YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"conversation": "string|null",
"message": {
"content": "string",
"attachments": []
},
"is_streaming": boolean
}'
參數:
chatbot_id
(路徑參數):對話機器人 IDconversation
(請求內容):可選的對話 ID,用於延續對話message.content
(請求內容):要發送的訊息內容message.attachments
(請求內容):附件陣列(如果有的話)is_streaming
(請求內容):是否使用串流回應
回應(非串流):
{
"content": "string",
"conversationId": "string"
}
回應(串流):
伺服器發送事件格式如下:
data: {
"content": "string",
"conversation_id": "string",
"done": boolean
}
注意事項:
對於串流回應,伺服器會發送多個包含部分內容的事件,直到回應完成
回應中返回的對話 ID 可用於後續請求中延續對話
串接成果
Last updated
Was this helpful?