[Feature] Add Cloudflare AI Gateway and Workers AI as separate providers - #1276
[Feature] Add Cloudflare AI Gateway and Workers AI as separate providers#1276pridemusvaire wants to merge 7 commits into
Conversation
Treat them as independent inference connections with distinct credentials, model prefixes, and docs so one Cloudflare token cannot satisfy both.
|
1 issue outstanding. See task
Reviewed 549d4fe |
OpenCode would otherwise load models.dev's ai-gateway-provider and skip Roomote's /v1/chat/completions path. Token help now requires Workers AI, which the /ai/v1 REST surface actually checks.
Helper inference now uses namespaced tokens, account ids, and gateway ids instead of models.dev CLOUDFLARE_ACCOUNT_ID. Also rewrite workers-ai/@cf slugs for /ai/v1 and accept underscore gateway ids.
Direct tasks skipped the Roomote Cloudflare provider merge, so self-hosted runs used models.dev env names. Keep tokens on the control plane in SELF_HOSTING and allow Workers AI /v1/responses.
The setup command already loads non-secret Cloudflare account and gateway ids. The web test still expected the pre-Cloudflare field list and failed CI.
|
Reviewed every thread on this PR. Roomote's original finding (direct-mode OpenCode never bound namespaced Cloudflare env vars) is fixed in 557dfb0. The later Roomote pass on b023ab2 reported no remaining code issues. Two extra gaps found while re-checking that review:
Both are fixed in 4a644b0. CI test list for non-secret Cloudflare identity fields is in b023ab2. |
|
@roomote please review again |
|
I started a PR review task for this request. See task |
…ference-providers # Conflicts: # apps/worker/src/run-task/agent-home.ts # packages/cloud-agents/src/server/__tests__/non-task-provider-usage.test.ts # packages/cloud-agents/src/server/non-task-provider-usage.ts # packages/cloud-agents/src/server/opencode-runtime.ts
| mergeAmazonBedrockProviderConfig, | ||
| mergeBedrockMantleOpenAiProviderConfig, | ||
| mergeBedrockMantleProviderConfig, | ||
| mergeCloudflareOpenCodeProviderConfig, |
There was a problem hiding this comment.
OPENCODE_CONFIG_CONTENT bypasses buildModelBackedOpenCodeConfigContent, but its else branch only adds the Bedrock registrations. Therefore helper inference with a custom config and R_MODEL=cloudflare-ai-gateway/... or cloudflare-workers-ai/... never calls mergeCloudflareOpenCodeProviderConfig, so it falls back to models.dev's shared Cloudflare env names instead of Roomote's namespaced credentials. Merge the Cloudflare provider registration into the custom-config path too.
Summary
cloudflare-ai-gateway/. Workers AI collects an API token and account ID only, then offers hosted@cf/models undercloudflare-workers-ai/.Test Plan
@roomote/types(model-provider-config,task-models,inference-gateway)@roomote/apifor chat/embeddings, bearer auth, gateway header vs no gateway header, and rejected account-admin paths