Problem
Several providers define their base URL independently in both the handler (constructor) and the fetcher, meaning a URL change requires edits in two places. The pattern was introduced with earlier providers and carried forward with each new addition.
Affected providers (handler + fetcher both hardcode the same URL):
| Provider |
Handler |
Fetcher |
opencode-go |
src/api/providers/opencode-go.ts:35 |
src/api/providers/fetchers/opencode-go.ts:7 |
vercel-ai-gateway |
src/api/providers/vercel-ai-gateway.ts:31 |
src/api/providers/fetchers/vercel-ai-gateway.ts:58 |
Additional providers with hardcoded URLs only in the handler (no fetcher constant to consolidate yet, but still worth noting for consistency):
fireworks, sambanova, unbound, xai, openai-codex, qwen-code, moonshot
Proposed Fix
Export each provider's base URL constant from packages/types/src/providers/<provider>.ts alongside the existing defaultModelId / defaultModelInfo exports, then import it in both the handler and the fetcher.
Example for opencode-go:
// packages/types/src/providers/opencode-go.ts
export const OPENCODE_GO_BASE_URL = "https://opencode.ai/zen/go/v1"
// src/api/providers/opencode-go.ts
import { ..., OPENCODE_GO_BASE_URL } from "@roo-code/types"
// ...
baseURL: OPENCODE_GO_BASE_URL,
// src/api/providers/fetchers/opencode-go.ts
import { ..., OPENCODE_GO_BASE_URL } from "@roo-code/types"
// remove local const OPENCODE_GO_BASE_URL
Scope
Start with opencode-go and vercel-ai-gateway (both have the handler+fetcher split). Extend to other providers opportunistically.
Surfaced during review of #319.
Problem
Several providers define their base URL independently in both the handler (constructor) and the fetcher, meaning a URL change requires edits in two places. The pattern was introduced with earlier providers and carried forward with each new addition.
Affected providers (handler + fetcher both hardcode the same URL):
opencode-gosrc/api/providers/opencode-go.ts:35src/api/providers/fetchers/opencode-go.ts:7vercel-ai-gatewaysrc/api/providers/vercel-ai-gateway.ts:31src/api/providers/fetchers/vercel-ai-gateway.ts:58Additional providers with hardcoded URLs only in the handler (no fetcher constant to consolidate yet, but still worth noting for consistency):
fireworks,sambanova,unbound,xai,openai-codex,qwen-code,moonshotProposed Fix
Export each provider's base URL constant from
packages/types/src/providers/<provider>.tsalongside the existingdefaultModelId/defaultModelInfoexports, then import it in both the handler and the fetcher.Example for
opencode-go:Scope
Start with
opencode-goandvercel-ai-gateway(both have the handler+fetcher split). Extend to other providers opportunistically.Surfaced during review of #319.