跳轉到

API 參考

本章整理 Codeer 的 Chat API 與 Batch API 端點。

https://api.codeer.ai/api/v1

這裡不涵蓋所有可能存在於 /api/v1 底下的內部端點或 workspace 管理端點。

驗證

每個請求都需要 API Key:

x-api-key: YOUR_API_KEY

回應格式

所有 API 都使用同一層 response envelope(data / message / error_code / pagination)。

Chat 端點

Method Endpoint
GET /chats/published-agents
POST /chats
GET /chats
PUT /chats/{chat_id}
GET /chats/{chat_id}/messages
POST /chats/{chat_id}/messages
POST /chats/{chat_id}/regenerate
POST /chats/{chat_id}/form-requests/{form_request_id}/submit
POST /chats/upload-file
POST /chats/{chat_id}/messages/{message_id}/feedbacks

詳細請看 Chat APISSE 串流

Batch 端點

Method Endpoint
POST /batches
GET /batches
GET /batches/{batch_id}
GET /batches/{batch_id}/results
POST /batches/{batch_id}/cancel

詳細請看 Batch API

external_user_id 說明

  • 某些 workspace 會用 whitelist mode 限制哪些 external user 可以進入體驗。
  • API key 請求會依 workspace 的 Allow API-key clients to bypass whitelist 設定決定是否仍檢查白名單。
  • 若啟用 bypass,API key 請求不需要白名單項目也能進入,但仍建議固定傳遞 external_user_id,讓 identity 與 history 分隔清楚。
  • 若停用 bypass,whitelist mode 下的 API key 請求必須使用已允許的 external_user_id,否則會收到 403error_code=14103

常見錯誤碼

HTTP error_code 說明
400 10006 請求格式錯誤
403 10001 權限不足
403 14103 Client user 不允許
404 10003 資源不存在
422 10002 驗證錯誤
500 10005 伺服器錯誤