Skip to content

feat: add multi-provider support with deployment-level LLM provider override#1

Draft
joshuadavidthomas wants to merge 2 commits into
mainfrom
claude/multi-provider-support-I2Gqf
Draft

feat: add multi-provider support with deployment-level LLM provider override#1
joshuadavidthomas wants to merge 2 commits into
mainfrom
claude/multi-provider-support-I2Gqf

Conversation

@joshuadavidthomas
Copy link
Copy Markdown
Member

No description provided.

…verride

Add infrastructure to route LLM calls through alternative providers
(e.g., Cloudflare AI Gateway) without changing the model registry.

A deployment-level `LLM_PROVIDER_OVERRIDE` env var replaces the provider
prefix before passing model config to OpenCode. For example, setting
`LLM_PROVIDER_OVERRIDE=cloudflare` routes `anthropic/claude-sonnet-4-6`
as `cloudflare/claude-sonnet-4-6` — OpenCode handles the rest natively.

Changes:
- shared: add PROVIDER_METADATA, ProviderId type, detectUpstreamProvider()
- modal-infra: remove hard ANTHROPIC_API_KEY requirement from llm_secrets
- modal-infra: 3-line provider override in sandbox entrypoint
- modal-infra: refactor bridge reasoning to detect upstream provider for
  gateway providers (cloudflare proxying to anthropic/openai)
- terraform: add llm_provider_override, cloudflare_ai_gateway_* variables
  and conditionally inject into Modal secrets
- tests: 14 new tests covering provider override, upstream detection,
  and gateway reasoning options (all 899 existing tests still pass)

https://claude.ai/code/session_01SfZd4jtoYjZUBXJyMNRNQ9
…Gateway

Verified against OpenCode docs (https://opencode.ai/docs/providers/):
- Provider ID is "cloudflare-ai-gateway" (not "cloudflare")
- Env vars are CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID,
  CLOUDFLARE_GATEWAY_ID (not CLOUDFLARE_AI_GATEWAY_*)
- OpenCode config needs a "provider" section to register the gateway
  provider with its available models

Also adds a test for non-gateway provider overrides.

https://claude.ai/code/session_01SfZd4jtoYjZUBXJyMNRNQ9
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.

2 participants