Skip to content

feat(provider): add gateway provider for OpenAI-compatible endpoints#1

Merged
mabry1985 merged 1 commit into
mainfrom
feat/gateway-provider-2026-05-24
May 24, 2026
Merged

feat(provider): add gateway provider for OpenAI-compatible endpoints#1
mabry1985 merged 1 commit into
mainfrom
feat/gateway-provider-2026-05-24

Conversation

@mabry1985
Copy link
Copy Markdown

Summary

All existing providers (codex, claude, acpx, cursor, opencode, grok, pi) shell out to a local CLI binary that has to be installed + OAuth'd on the host. That's a poor fit for containerized agent deployments where the only available LLM channel is an HTTP endpoint.

This adds a gateway provider that POSTs the already-assembled prompt to an OpenAI-compatible /chat/completions endpoint with structured outputs (response_format: json_schema). No subprocess; no extra CLI to install; same JSON contract as every other provider.

Designed for the protoLabs LiteLLM gateway:

  • Inside docker network: http://gateway:4000/v1
  • Externally: https://api.proto-labs.ai/v1

…but works against any OpenAI-compatible endpoint (vanilla OpenAI, vLLM, LM Studio, Ollama with the OpenAI shim).

Config

Env Default Notes
GATEWAY_API_KEY (preferred) or OPENAI_API_KEY required Bearer token
OPENAI_BASE_URL https://api.proto-labs.ai/v1 Trailing slashes stripped
CLAWPATCH_GATEWAY_MODEL protolabs/smart --model on the CLI wins
CLAWPATCH_GATEWAY_TIMEOUT_MS 300000 (5 min) Reasoning models on large features can be slow
--reasoning-effort n/a Forwarded as reasoning_effort body field

Why this can be the minimal provider

buildReviewPrompt / buildMapPrompt / buildFixPrompt already inline the relevant file contents as Files blocks, so the gateway provider needs zero file IO — it's effectively the smallest possible provider: prompt in, JSON out.

Smoke-test results

Verified end-to-end against api.proto-labs.ai/v1:

  • 401 path: missing/wrong key returns the LiteLLM auth error verbatim ✅
  • Successful request reaches the gateway and back through the wire ✅
  • (Cloudflare 524 hit on full reviews because reasoning takes >100s — irrelevant for the in-cluster http://gateway:4000 path which is the actual deploy target.)

Test plan

  • 11 new unit tests on the config helper covering env precedence, URL normalization, model resolution, timeout parsing, and the no-API-key auth-error path
  • pnpm test --run — 724 pass / 1 pre-existing skipped
  • pnpm typecheck clean

Follow-ups

  • Wire clawpatch ci --since <ref> --provider gateway into Quinn's pr_review (separate PR in protoWorkstacean)
  • Bake clawpatch into the workstacean Docker image

All existing providers (codex, claude, acpx, cursor, ...) shell out to a
local CLI binary that has to be installed + OAuth'd on the host. That's a
poor fit for containerized agent deployments where the only available
LLM channel is an HTTP endpoint (LiteLLM gateway, vLLM, vanilla OpenAI).

This adds a `gateway` provider that POSTs the already-assembled prompt
to an OpenAI-compatible /chat/completions endpoint with structured
outputs (response_format: json_schema). No subprocess; no extra CLI to
install; same JSON contract as every other provider.

Designed for the protoLabs LiteLLM gateway
(internally http://gateway:4000/v1, externally https://api.proto-labs.ai/v1)
but works against any OpenAI-compatible endpoint — vanilla OpenAI, vLLM,
LM Studio, Ollama with the OpenAI shim, etc.

Configuration:

  GATEWAY_API_KEY       (preferred) or OPENAI_API_KEY  — Bearer token
  OPENAI_BASE_URL       default https://api.proto-labs.ai/v1
  CLAWPATCH_GATEWAY_MODEL
                        default protolabs/smart;
                        --model on the CLI overrides
  CLAWPATCH_GATEWAY_TIMEOUT_MS
                        default 300000 (5 min — reasoning models on big
                        features can be slow)
  --reasoning-effort    forwarded as `reasoning_effort` body field

Because the buildReviewPrompt / buildMapPrompt / buildFixPrompt helpers
already inline the relevant file contents as Files blocks, the gateway
provider needs zero file IO. It's effectively the minimal provider
implementation: prompt in, JSON out.

The `check()` method validates env + returns a fingerprint string
(model + base URL) without making a network call — `clawpatch doctor`
won't spend tokens on a probe and won't time out when offline.

+11 tests covering env precedence (GATEWAY_API_KEY > OPENAI_API_KEY),
URL normalization (trailing slashes), model precedence
(--model > CLAWPATCH_GATEWAY_MODEL > default), timeout parsing
(garbage values fall back), check() fingerprint format, and the
no-API-key auth-error path. 724 pass / 1 pre-existing skipped.
@mabry1985 mabry1985 merged commit 2eb6ea4 into main May 24, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant