OpenAI Chat Completions (HTTP)
OpenClaw का Gateway एक छोटा OpenAI‑संगत Chat Completions एंडपॉइंट प्रदान कर सकता है। यह endpoint डिफ़ॉल्ट रूप से अक्षम है। पहले इसे config में सक्षम करें।POST /v1/chat/completions- Gateway के समान पोर्ट (WS + HTTP मल्टीप्लेक्स):
http://<gateway-host>:<port>/v1/chat/completions
openclaw agent), इसलिए रूटिंग/अनुमतियाँ/विन्यास आपके Gateway से मेल खाते हैं।
प्रमाणीकरण
Gateway auth configuration का उपयोग करता है। एक bearer टोकन भेजें:Authorization: Bearer <token>
- जब
gateway.auth.mode="token", तबgateway.auth.token(याOPENCLAW_GATEWAY_TOKEN) का उपयोग करें। - जब
gateway.auth.mode="password", तबgateway.auth.password(याOPENCLAW_GATEWAY_PASSWORD) का उपयोग करें। - यदि
gateway.auth.rateLimitकॉन्फ़िगर है और बहुत अधिक auth विफलताएँ होती हैं, तो endpointRetry-Afterके साथ429लौटाता है।
एजेंट का चयन
कोई कस्टम हेडर आवश्यक नहीं है: OpenAI केmodel फ़ील्ड में एजेंट id एन्कोड करें:
model: "openclaw:<agentId>"(उदाहरण:"openclaw:main","openclaw:beta")model: "agent:<agentId>"(उपनाम)
x-openclaw-agent-id: <agentId>(डिफ़ॉल्ट:main)
- सत्र रूटिंग पर पूर्ण नियंत्रण के लिए
x-openclaw-session-key: <sessionKey>।
एंडपॉइंट सक्षम करना
gateway.http.endpoints.chatCompletions.enabled को true पर सेट करें:
एंडपॉइंट अक्षम करना
gateway.http.endpoints.chatCompletions.enabled को false पर सेट करें:
सत्र व्यवहार
डिफ़ॉल्ट रूप से यह एंडपॉइंट प्रति अनुरोध stateless होता है (प्रत्येक कॉल पर एक नया सत्र कुंजी उत्पन्न होती है)। यदि अनुरोध में OpenAI काuser स्ट्रिंग शामिल है, तो Gateway उससे एक स्थिर सत्र कुंजी व्युत्पन्न करता है, ताकि दोहराए गए कॉल एक ही एजेंट सत्र साझा कर सकें।
स्ट्रीमिंग (SSE)
Server‑Sent Events (SSE) प्राप्त करने के लिएstream: true सेट करें:
Content-Type: text/event-stream- प्रत्येक इवेंट पंक्ति
data: <json>होती है - स्ट्रीम
data: [DONE]के साथ समाप्त होती है