Experiment openclaw

An OpenAI chat-completions compatible HTTP endpoint can serve as openclaw's external API surface, allowing any tool that speaks the OpenAI wire format to use openclaw as a drop-in backend without custom adapters.

308 commits in 60 minutes across 4 sessions ($2.76). The gateway shipped and was immediately exercised by the sandbox explain inspector, confirming th

ai-agentsopenclawgatewayopenai
Hypothesis

An OpenAI chat-completions compatible HTTP endpoint can serve as openclaw's external API surface, allowing any tool that speaks the OpenAI wire format to use openclaw as a drop-in backend without custom adapters.

Result: confirmed
Key Findings

308 commits in 60 minutes across 4 sessions ($2.76). The gateway shipped and was immediately exercised by the sandbox explain inspector, confirming the API surface supports both chat and explain-before-execute flows. The WhatsApp ack-reaction was decoupled from generic reactions in the same session, validating that platform-specific behavior can coexist with the generic gateway. CLI backend fallback provides graceful degradation when downstream providers are unreachable. The next day (Jan 11), the plugin architecture migration built directly on top of the gateway surface, confirming it was the correct foundation layer.

Changelog

DateSummary
2026-04-28Audit pass: frontmatter + structure normalization
2026-01-10Initial creation

Hypothesis

By January 10, openclaw was a standalone messaging-agent daemon with no standard API surface. External tools and agent frameworks could not integrate without writing custom adapters that understood openclaw’s internal protocol. The hypothesis was that implementing an OpenAI chat-completions compatible HTTP endpoint: matching the wire format and streaming semantics exactly: would transform openclaw from a standalone tool into a drop-in backend for the broader OpenAI ecosystem, with zero changes required on the client side.

Method

The implementation targeted exact parity with the OpenAI chat-completions API:

  1. Matching request/response wire format (model, messages, temperature, etc.)
  2. Matching SSE streaming semantics for streaming responses
  3. Routing through openclaw’s provider abstraction so any supported provider can serve the request

Additional features shipped in the same session to validate the architecture:

  • Sandbox explain inspector: “show me what you’d do before running it” through the same API surface
  • CLI backend fallback: graceful degradation to local mode when downstream providers are unreachable
  • Auth flow consolidation: refactor: unify configure auth choice
  • Tailnet discovery fallback: automatic peer discovery on Tailscale networks

Results

308 commits, 29,398 additions, 7,989 deletions across 4 sessions in 60 minutes. Under a penny per commit in session cost.

The gateway worked on first contact with two immediate consumers:

  1. The sandbox explain inspector exercised the gateway’s chat-completions path for task explanation before execution
  2. The CLI backend fallback validated that the gateway degrades gracefully rather than failing hard

The WhatsApp ack-reaction redesign (shipping the same day) validated that platform-specific behavior can be cleanly decoupled from the generic gateway. WhatsApp’s reaction semantics are different enough from Discord and Telegram that sharing code was producing subtle wrong behavior. Making it whatsapp-specific while keeping the gateway generic confirmed the abstraction boundary was in the right place.

The next day’s plugin architecture migration (Jan 11, 216 commits) built directly on the gateway surface, with Copilot and Chutes providers landing cleanly. This confirmed the gateway was the correct foundation layer for the provider abstraction.

Findings

  1. Adapter surface design works. Letting the world keep talking in the shape it already knows (OpenAI wire format) and swapping the implementation underneath is cheaper than inventing a new protocol and writing adapters.

  2. Ship the gateway before the plugin boundary. The gateway surface made the cost of hardcoded provider wiring obvious, which drove the Jan 11 plugin architecture migration. Sequencing matters: gateway first, then plugin abstraction.

  3. Explain-before-execute through a standard API is a different product. Pairing the sandbox explain inspector with the gateway means openclaw is not just a chat backend but a task-approval surface accessible through the same familiar API.

Next Steps

The gateway surface made the cost of hardcoded provider wiring obvious, which drove the Jan 11 plugin architecture migration. The plugin boundary (providers as swappable modules) was the next structural move, built directly on the gateway foundation.

Source