openclaw - 💡(How to fix) Fix github-copilot: Gemini models route to unsupported /responses endpoint, and openai-completions transport bypasses Copilot IDE auth headers [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#74159Fetched 2026-04-30 06:27:53
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
commented ×1cross-referenced ×1mentioned ×1subscribed ×1

github-copilot/gemini-3-flash-preview (and likely all Gemini//chat/completions-only Copilot models) fail 100% of the time and silently fall back to the configured non-Copilot fallback (e.g. anthropic/claude-sonnet-4-6), generating substantial unintended Anthropic API spend.

Two bugs in series in dist/extensions/github-copilot/:

Error Message

  1. Add "api": "openai-completions" to the model definition in openclaw.json and retry. Error changes to:

Root Cause

github-copilot/gemini-3-flash-preview (and likely all Gemini//chat/completions-only Copilot models) fail 100% of the time and silently fall back to the configured non-Copilot fallback (e.g. anthropic/claude-sonnet-4-6), generating substantial unintended Anthropic API spend.

Two bugs in series in dist/extensions/github-copilot/:

Fix Action

Fix / Workaround

Happy to test a patched build locally.

Code Example

function resolveCopilotTransportApi(modelId) {
  return (normalizeOptionalLowercaseString(modelId) ?? "").includes("claude")
    ? "anthropic-messages"
    : "openai-responses";
}

---

400 unsupported_api_for_model: model gemini-3-flash-preview is not supported via Responses API.

---

function wrapCopilotProviderStream(ctx) {
  return wrapCopilotOpenAIResponsesStream(wrapCopilotAnthropicStream(ctx.streamFn));
}

---

400 bad request: missing Editor-Version header for IDE auth

---

openclaw capability model run --model github-copilot/gemini-3-flash-preview --prompt "ping"

---

[model-fallback/decision] decision=candidate_failed
     requested=github-copilot/gemini-3-flash-preview
     reason=format
     detail=400 building HTTP client: selecting model endpoint:
            scheduler enqueue for model endpoint selection:
            no model endpoints available given user constraints

---

400 bad request: missing Editor-Version header for IDE auth
RAW_BUFFERClick to expand / collapse

Summary

github-copilot/gemini-3-flash-preview (and likely all Gemini//chat/completions-only Copilot models) fail 100% of the time and silently fall back to the configured non-Copilot fallback (e.g. anthropic/claude-sonnet-4-6), generating substantial unintended Anthropic API spend.

Two bugs in series in dist/extensions/github-copilot/:

Bug 1 — resolveCopilotTransportApi routes Gemini to the wrong endpoint

dist/models-CZL3_C6Y.js:

function resolveCopilotTransportApi(modelId) {
  return (normalizeOptionalLowercaseString(modelId) ?? "").includes("claude")
    ? "anthropic-messages"
    : "openai-responses";
}

Any non-Claude Copilot model is routed through POST /responses. GitHub Copilot rejects this for Gemini:

400 unsupported_api_for_model: model gemini-3-flash-preview is not supported via Responses API.

Direct verification (curl):

  • POST https://api.githubcopilot.com/responses with model: gemini-3-flash-preview400 unsupported_api_for_model
  • POST https://api.githubcopilot.com/chat/completions with same model → 200 OK

Bug 2 — openai-completions transport bypasses Copilot IDE-header injection

dist/stream-Dy0kutKG.js:

function wrapCopilotProviderStream(ctx) {
  return wrapCopilotOpenAIResponsesStream(wrapCopilotAnthropicStream(ctx.streamFn));
}

Only anthropic-messages and openai-responses are wrapped to inject Copilot's required Editor-Version / Copilot-Integration-Id / User-Agent headers (via buildCopilotRequestHeadersbuildCopilotDynamicHeaders). openai-completions is not wrapped, so any model routed through chat-completions hits:

400 bad request: missing Editor-Version header for IDE auth

Confirmed by setting "api": "openai-completions" override on gemini-3-flash-preview in openclaw.json — request now goes to /chat/completions (Bug 1 bypassed) but immediately fails with "missing Editor-Version header for IDE auth" (Bug 2 hits).

This is the same class of issue as #71538 (closed 2026-04-25) but for the openai-completions transport path, which that PR did not cover.

Environment

  • OpenClaw: 2026.4.24 (cbcfdf6)
  • Provider: github-copilot (device login, Pro+ plan with Gemini access verified)
  • Model affected: github-copilot/gemini-3-flash-preview (also: gemini-3.1-pro-preview, gemini-2.5-pro, and any non-Claude/non-responses-supporting model)
  • Available models confirmed via GET https://api.githubcopilot.com/models — Gemini IDs are listed for the account.

Reproduction

  1. Set github-copilot/gemini-3-flash-preview as a heartbeat model or run:
    openclaw capability model run --model github-copilot/gemini-3-flash-preview --prompt "ping"
  2. Observe in logs:
    [model-fallback/decision] decision=candidate_failed
      requested=github-copilot/gemini-3-flash-preview
      reason=format
      detail=400 building HTTP client: selecting model endpoint:
             scheduler enqueue for model endpoint selection:
             no model endpoints available given user constraints
  3. Add "api": "openai-completions" to the model definition in openclaw.json and retry. Error changes to:
    400 bad request: missing Editor-Version header for IDE auth

Impact

  • Silent cost amplification. Gemini was configured as the heartbeat model on three agents (1h cadence × 24h × 3 agents = ~72 calls/day intended free). All 72 calls/day fell through to anthropic/claude-sonnet-4-6 fallback. Plus subagent spawns. Combined: ~287 fallback events/day on this model alone, materially contributing to a multi-day Anthropic bill spike.
  • The primary→fallback flow makes this invisible by design: the request "succeeds" (just not on the requested provider), so users only notice via the bill.

Proposed Fix

  1. resolveCopilotTransportApi should return "openai-completions" for known Gemini model IDs (or any model ID not on Copilot's Responses-API allowlist).
  2. wrapCopilotProviderStream should also wrap openai-completions with buildCopilotRequestHeaders.
  3. Optional: surface a fast-path warning when model-fallback/decision shows reason=format for the same primary provider repeatedly (signal: "your primary is broken, you're paying for fallback").

Happy to test a patched build locally.

extent analysis

TL;DR

The most likely fix involves updating the resolveCopilotTransportApi function to correctly route Gemini models to the openai-completions endpoint and modifying the wrapCopilotProviderStream function to include the necessary headers for openai-completions requests.

Guidance

  • Update the resolveCopilotTransportApi function to return "openai-completions" for known Gemini model IDs, ensuring they are routed to the correct endpoint.
  • Modify the wrapCopilotProviderStream function to wrap openai-completions requests with the necessary Editor-Version, Copilot-Integration-Id, and User-Agent headers using buildCopilotRequestHeaders.
  • Consider implementing a warning system to alert users when their primary model is consistently failing and defaulting to a fallback provider, indicating a potential issue with their configuration.

Example

function resolveCopilotTransportApi(modelId) {
  // Add a condition to return "openai-completions" for Gemini models
  if (modelId.includes("gemini")) {
    return "openai-completions";
  }
  // Existing logic for other models
  return (normalizeOptionalLowercaseString(modelId) ?? "").includes("claude")
    ? "anthropic-messages"
    : "openai-responses";
}

Notes

The proposed fix assumes that the openai-completions endpoint is the correct destination for Gemini models. It's essential to verify this and test the changes thoroughly to ensure they resolve the issue without introducing new problems.

Recommendation

Apply the proposed fix by updating the resolveCopilotTransportApi and wrapCopilotProviderStream functions as described, allowing Gemini models to be correctly routed and authenticated. This should mitigate the silent cost amplification issue caused by the current fallback behavior.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING