anomalyco / anomalyco/opencode

Native Cloudflare gateway key is discarded during model resolution

Open
#48,293 0 comments 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Sep 10, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

An explicitly enabled native Cloudflare AI Gateway provider loses its configured
gateway authentication when it has no integration credential. The provider creates
cf-aig-authorization, but ModelResolver.layer replaces its auth with Auth.none
because hasConfiguredAuth does not recognize gatewayApiKey.

This prevents gateway-key-only configurations from sending their gateway credential.

OpenCode version

V2 source at 98a36fb1a4dbf6843e18710bf21dba71c5efdb78. The affected resolver and
provider code is unchanged at f3ef84556a30a628d69aa9f456e7f0dc638f8ea3.

Steps to reproduce

Use this provider configuration with no active integration credential. The URL and
key are fixtures; no network request is needed to reproduce the resolver behavior.

{
  "providers": {
    "gateway": {
      "package": "@opencode/ai/providers/cloudflare-ai-gateway",
      "settings": {
        "baseURL": "https://gateway.test/v1/compat",
        "gatewayApiKey": "gateway-fixture"
      },
      "models": { "openai/gpt-4o-mini": {} }
    }
  }
}

Resolve that model through ModelResolver.layer, then apply the resolved route's
auth to its request headers. cf-aig-authorization is absent. Constructing the same
model directly through fromCatalogModel retains Bearer gateway-fixture.

Expected: model resolution preserves the configured gateway header, without adding
an upstream Authorization header. Reproduced in a fixture-only resolver test,
not with a live Cloudflare request.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.