anomalyco / anomalyco/opencode
Cloudflare REST route ignores AI Gateway control options
@rekram1-node is already working on this.
Since Aug 26, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
When OpenCode is routed through Cloudflare's AI Gateway using the REST (/workers/ai/v1/...) route, AI Gateway control options (cacheTtl, cacheKey, metadata, cacheStatus, etc.) configured via provider.cloudflare.options are dropped. The OpenAI-compatible chat route applies them, but the REST branch constructs its request without forwarding the gateway control headers, so caching/metadata policies are silently ignored on that path.
Expected
Both the OpenAI-compatible and REST Cloudflare routes honor the same options (gateway id, account id, api key, and control options) and attach the corresponding cf-aig-* control headers.
Actual
packages/opencode/src/provider/provider.ts builds the REST request body and URL but does not include the aiGateway* control parameters that the OpenAI-compatible branch (aiGateway) forwards. Requests through the REST route therefore never carry cf-aig-cache_ttl / cf-aig-metadata / etc.
Environment
- opencode version: dev
- provider:
cloudflarewithoptions.accountId/gatewayId/gatewayApiKeyand anycf-aig-*control option, using the REST endpoint
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.