@@ -78,6 +78,14 @@ Auth matrix:
|
78 | 78 | |
79 | 79 | See [Security](/gateway/security) and [Remote access](/gateway/remote). |
80 | 80 | |
| 81 | +## When to use this endpoint |
| 82 | + |
| 83 | +Use `/v1/chat/completions` when you are integrating tooling or a trusted app-side backend with an existing gateway and can safely hold gateway operator credentials. |
| 84 | + |
| 85 | +- Prefer this over adding a new built-in channel when your integration is just another operator/client surface for the same gateway. |
| 86 | +- For native mobile clients that connect directly to a remote gateway, prefer [WebChat](/web/webchat) or the [Gateway Protocol](/gateway/protocol) and implement the paired-device bootstrap/device-token flow so the device does not need a shared HTTP token/password. |
| 87 | +- Build a channel plugin instead when you are integrating an external messaging network with its own users, rooms, webhook delivery, or outbound transport. See [Building plugins](/plugins/building-plugins). |
| 88 | + |
81 | 89 | ## Agent-first model contract |
82 | 90 | |
83 | 91 | OpenClaw treats the OpenAI `model` field as an **agent target**, not a raw provider model id. |
@@ -136,6 +144,8 @@ By default the endpoint is **stateless per request** (a new session key is gener
|
136 | 144 | |
137 | 145 | If the request includes an OpenAI `user` string, the Gateway derives a stable session key from it, so repeated calls can share an agent session. |
138 | 146 | |
| 147 | +For custom apps, the safest default is to reuse the same `user` value per conversation thread. Avoid account-level identifiers unless you explicitly want multiple conversations or devices to share one OpenClaw session. Use `x-openclaw-session-key` when you need explicit routing control across multiple clients or threads. |
| 148 | + |
139 | 149 | ## Why this surface matters |
140 | 150 | |
141 | 151 | This is the highest-leverage compatibility set for self-hosted frontends and tooling: |
@@ -284,6 +294,21 @@ If that returns `openclaw/default`, most Open WebUI setups can connect with the
|
284 | 294 | |
285 | 295 | ## Examples |
286 | 296 | |
| 297 | +Stable session for one app conversation: |
| 298 | + |
| 299 | +```bash |
| 300 | +curl -sS http://127.0.0.1:18789/v1/chat/completions \ |
| 301 | + -H 'Authorization: Bearer YOUR_TOKEN' \ |
| 302 | + -H 'Content-Type: application/json' \ |
| 303 | + -d '{ |
| 304 | + "model": "openclaw/default", |
| 305 | + "user": "conv:YOUR_CONVERSATION_ID", |
| 306 | + "messages": [{"role":"user","content":"Summarize my tasks for today"}] |
| 307 | + }' |
| 308 | +``` |
| 309 | + |
| 310 | +Reuse the same `user` value on later calls for that conversation to continue the same agent session. |
| 311 | + |
287 | 312 | Non-streaming: |
288 | 313 | |
289 | 314 | ```bash |
|