logo
開發者文件
搜尋
創建對話 ID

創建對話 ID

用於請求生成並取得 conversation_id,此識別碼是用戶與 Agent 之間對話的唯一標識。用戶屬性、長期記憶與短期記憶都會綁定於 conversation_id

ID 名稱 說明
conversation_id agent_iduser_id 共同生成的對話識別碼,用於進行用戶與 Agent 之間的多輪對話。單一 conversation_id 通常包含多個 message_id
message_id 由「用戶發送的訊息」與「Agent 回覆的訊息」共同生成的訊息識別碼,代表用戶與 Agent 之間的一輪對話。message_id 必須隸屬於某個 conversation_id

請求方法

POST

請求 URL

https://api-${endpoint}.gptbots.ai/v1/conversation

請求驗證

請參考 API 總覽 以取得驗證說明。

請求

請求範例

curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/conversation' \ -H 'Authorization: Bearer ${API Key}' \ -H 'Content-Type: application/json' \ -d '{ "user_id": "your_user_id" }'
                      
                      curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/conversation' \
  -H 'Authorization: Bearer ${API Key}' \
  -H 'Content-Type: application/json' \
  -d '{
        "user_id": "your_user_id"
}'

                    
此代碼塊在浮窗中顯示

請求標頭

欄位 類型 說明
Authorization Bearer ${API Key} 使用 Authorization: Bearer ${API Key} 作為驗證。API 金鑰可從 API Key 頁面取得。
Content-Type application/json 資料類型,設為 application/json。

請求參數

欄位 類型 必填 說明
user_id string 開發者自訂的用戶 ID,用於唯一識別 Agent 內的用戶。最大長度為 32 個字元。

回應

回應範例

{ "conversation_id": "657303a8a764d47094874bbe" }
                      
                      {
  "conversation_id": "657303a8a764d47094874bbe" 
}

                    
此代碼塊在浮窗中顯示

成功回應

欄位 類型 說明
conversation_id string 對話識別碼。

失敗回應

欄位 類型 說明
code int 錯誤代碼。
message string 錯誤細節。

錯誤代碼

錯誤代碼 錯誤訊息
40000 參數錯誤
40127 開發者驗證失敗
40378 Agent 已刪除