The GoClaw Gateway exposes an OpenAI-compatible interface, allowing it to act as a drop-in proxy for tools like Cursor, Continue.dev, or any library that supports the OpenAI API.
/v1/chat/completionsMethod: POST
Implements the standard OpenAI Chat Completions API.
Key Features:
stream: true using Server-Sent Events (SSE). Besides the usual chat.completion.chunk frames, a stream can carry data: {"buffer_reset":true} (the reply is being retried: discard the text received so far) and data: {"error":{"message":"…"}}, which ends the stream with no finish chunk and no data: [DONE].content must be a string. Content sent as an array of parts (text and images) is refused with 400.model parameter is echoed back in the response and does not select an agent or a model. max_tokens and temperature are read and ignored./subagents is a GoClaw subagent command, answered without the model: /subagents spawn <agent_id> <task>, /subagents list, /subagents status <run_id>, /subagents stop <run_id>.Example Request:
curl http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-token" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "How many files are in the current directory?"}]
}'
/v1/modelsMethod: GET
Not implemented: the gateway answers 404. Use the default model or any string, as all traffic goes to the default agent.
The gateway token is always required: the gateway does not start without gateway.auth.token. Provide it in one of the following ways:
Authorization: Bearer <your-token>X-GoClaw-Token: <your-token>?token=<your-token> (for browser clients that cannot set a header, such as EventSource)X-Goclaw-Token cookie a browser receives from the Web UI's login link?auth_code= is a different thing: a one-time login code the gateway prints at startup, which
exchanges itself for a session cookie. It is not the token.
When a request is received via the OpenAI compatibility layer:
agents.default, else the agent marked default: true, else the first agent in agents.list, else main.user message is the prompt; the system, user and assistant messages before it are the conversation history. GoClaw keeps no history for this endpoint: a session openai-compat:<client-ip> is created, but nothing is written to it, so send the whole conversation in messages on every request.ai.fallback serves it (see Provider Fallback). When every provider fails, the error is returned as an OpenAI-style error ({"error":{"message":…}}, status 500 when not streaming).prompt_tokens, completion_tokens) are estimated based on character count (~4 characters per token).To use GoClaw in your IDE:
http://your-gateway:8080/v1.