OpenClaw 的 Gateway 可以提供與 OpenResponses 相容的Documentation Index
Fetch the complete documentation index at: https://docs.openclaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
POST /v1/responses 端點。
此端點預設為停用。請先在設定中啟用。
POST /v1/responses- 與 Gateway 相同的連接埠(WS + HTTP 多工):
http://<gateway-host>:<port>/v1/responses
openclaw agent 相同的程式碼路徑),因此路由/權限/設定會與你的 Gateway 相符。
驗證、安全性與路由
操作行為與 OpenAI Chat Completions 相符:- 使用相符的 Gateway HTTP 驗證路徑:
- shared-secret 驗證(
gateway.auth.mode="token"或"password"):Authorization: Bearer <token-or-password> - trusted-proxy 驗證(
gateway.auth.mode="trusted-proxy"):來自已設定受信任代理來源的身分感知代理標頭;同主機 loopback 代理需要明確設定gateway.auth.trustedProxy.allowLoopback = true - private-ingress open auth(
gateway.auth.mode="none"):無驗證標頭
- shared-secret 驗證(
- 將此端點視為 gateway 執行個體的完整 operator 存取權
- 對於 shared-secret 驗證模式(
token和password),忽略較窄的 bearer 宣告x-openclaw-scopes值,並還原一般完整 operator 預設值 - 對於帶有受信任身分的 HTTP 模式(例如 trusted proxy auth 或
gateway.auth.mode="none"),若存在x-openclaw-scopes則遵循它,否則回退至一般 operator 預設 scope 集合 - 使用
model: "openclaw"、model: "openclaw/default"、model: "openclaw/<agentId>"或x-openclaw-agent-id選取 agent - 當你想覆寫所選 agent 的後端模型時,使用
x-openclaw-model - 使用
x-openclaw-session-key進行明確的工作階段路由 - 當你想要非預設的合成 ingress 頻道情境時,使用
x-openclaw-message-channel
gateway.auth.mode="token"或"password"+Authorization: Bearer ...- 證明持有共用的 gateway operator 密鑰
- 忽略較窄的
x-openclaw-scopes - 還原完整的預設 operator scope 集合:
operator.admin、operator.approvals、operator.pairing、operator.read、operator.talk.secrets、operator.write - 將此端點上的聊天回合視為 owner-sender 回合
- 帶有受信任身分的 HTTP 模式(例如 trusted proxy auth,或私有 ingress 上的
gateway.auth.mode="none")- 當標頭存在時遵循
x-openclaw-scopes - 當標頭不存在時回退至一般 operator 預設 scope 集合
- 只有在呼叫者明確縮窄 scope 並省略
operator.admin時,才會失去 owner 語意
- 當標頭存在時遵循
gateway.http.endpoints.responses.enabled 啟用或停用此端點。
相同的相容性介面也包含:
GET /v1/modelsGET /v1/models/{id}POST /v1/embeddingsPOST /v1/chat/completions
openclaw/default、embeddings pass-through,以及後端模型覆寫如何互相配合的權威說明,請參閱 OpenAI Chat Completions 與模型清單與 agent 路由。
工作階段行為
預設情況下,此端點是每次請求無狀態(每次呼叫都會產生新的工作階段金鑰)。 如果請求包含 OpenResponsesuser 字串,Gateway 會從中衍生穩定的工作階段金鑰,因此重複呼叫可以共用 agent 工作階段。
請求形狀(支援)
請求遵循 OpenResponses API,使用以項目為基礎的輸入。目前支援:input:字串或項目物件陣列。instructions:合併至系統提示。tools:用戶端工具定義(function tools)。tool_choice:篩選或要求用戶端工具。stream:啟用 SSE 串流。max_output_tokens:盡力而為的輸出限制(取決於 provider)。user:穩定的工作階段路由。
max_tool_callsreasoningmetadatastoretruncation
previous_response_id:當請求維持在相同 agent/user/請求的工作階段範圍內時,OpenClaw 會重用先前的回應工作階段。
項目(輸入)
message
角色:system、developer、user、assistant。
system和developer會附加到系統提示。- 最新的
user或function_call_output項目會成為「目前訊息」。 - 較早的 user/assistant 訊息會作為脈絡歷史包含在內。
function_call_output(以回合為基礎的工具)
將工具結果傳回模型:
reasoning 和 item_reference
為了 schema 相容性而接受,但在建構提示時會忽略。
工具(用戶端 function tools)
使用tools: [{ type: "function", function: { name, description?, parameters? } }] 提供工具。
如果 agent 決定呼叫工具,回應會傳回 function_call 輸出項目。
接著你要傳送含有 function_call_output 的後續請求,以繼續該回合。
圖片(input_image)
支援 base64 或 URL 來源:
image/jpeg、image/png、image/gif、image/webp、image/heic、image/heif。
最大大小(目前):10MB。
檔案(input_file)
支援 base64 或 URL 來源:
text/plain、text/markdown、text/html、text/csv、
application/json、application/pdf。
最大大小(目前):5MB。
目前行為:
- 檔案內容會被解碼並加入系統提示,而不是使用者訊息, 因此它會保持短暫存在(不會持久化到工作階段歷史中)。
- 解碼後的檔案文字會先包裝為不受信任的外部內容,再加入提示, 因此檔案位元組會被視為資料,而不是受信任的指令。
- 注入區塊會使用明確的邊界標記,例如
<<<EXTERNAL_UNTRUSTED_CONTENT id="...">>>/<<<END_EXTERNAL_UNTRUSTED_CONTENT id="...">>>,並包含Source: External中繼資料行。 - 此檔案輸入路徑有意省略冗長的
SECURITY NOTICE:橫幅,以保留提示預算;邊界標記和中繼資料仍會保留。 - PDF 會先解析文字。如果找到的文字很少,前幾頁會被光柵化為圖片並傳給模型,且注入的檔案區塊會使用
[PDF content rendered to images]佔位符。
document-extract Plugin 提供,它使用適合 Node 的 pdfjs-dist legacy build(無 worker)。現代 PDF.js build 預期瀏覽器 worker/DOM 全域物件,因此 Gateway 不使用它。
URL 擷取預設值:
files.allowUrl:trueimages.allowUrl:truemaxUrlParts:8(每個請求中基於 URL 的input_file+input_image部分總數)- 請求會受到防護(DNS 解析、私人 IP 封鎖、重新導向上限、逾時)。
- 每種輸入類型都支援選用的主機名稱允許清單(
files.urlAllowlist、images.urlAllowlist)。- 精確主機:
"cdn.example.com" - 萬用字元子網域:
"*.assets.example.com"(不符合 apex) - 空白或省略的允許清單表示沒有主機名稱允許清單限制。
- 精確主機:
- 若要完全停用基於 URL 的擷取,請設定
files.allowUrl: false和/或images.allowUrl: false。
檔案 + 圖片限制(設定)
預設值可在gateway.http.endpoints.responses 下調整:
maxBodyBytes:20MBmaxUrlParts:8files.maxBytes:5MBfiles.maxChars:200kfiles.maxRedirects:3files.timeoutMs:10sfiles.pdf.maxPages:4files.pdf.maxPixels:4,000,000files.pdf.minTextChars:200images.maxBytes:10MBimages.maxRedirects:3images.timeoutMs:10s- HEIC/HEIF
input_image來源會被接受,並在傳送給 provider 前正規化為 JPEG。
- URL 允許清單會在擷取前與重新導向跳轉時強制執行。
- 將主機名稱加入允許清單並不會繞過私人/內部 IP 封鎖。
- 對於暴露在網際網路上的 gateway,除了應用程式層級防護外,也請套用網路輸出控制。 請參閱安全性。
串流(SSE)
設定stream: true 以接收 Server-Sent Events(SSE):
Content-Type: text/event-stream- 每一行事件為
event: <type>與data: <json> - 串流以
data: [DONE]結束
response.createdresponse.in_progressresponse.output_item.addedresponse.content_part.addedresponse.output_text.deltaresponse.output_text.doneresponse.content_part.doneresponse.output_item.doneresponse.completedresponse.failed(發生錯誤時)
使用量
當底層 provider 回報 token 數量時,會填入usage。
OpenClaw 會在這些計數器到達下游狀態/工作階段介面前,正規化常見的 OpenAI 風格別名,包括 input_tokens / output_tokens
和 prompt_tokens / completion_tokens。
錯誤
錯誤使用如下 JSON 物件:401遺漏/無效驗證400無效請求本文405方法錯誤