fix(core): send catalog models to a configured provider baseURL by bercedev · Pull Request #56069 · anomalyco/opencode · GitHub
Skip to content

fix(core): send catalog models to a configured provider baseURL - #56069

Closed
bercedev wants to merge 3 commits into
anomalyco:devfrom
bercedev:fix/provider-baseurl-catalog-models
Closed

bercedev wants to merge 3 commits into
anomalyco:devfrom
bercedev:fix/provider-baseurl-catalog-models

Conversation

@bercedev

@bercedev bercedev commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #56064

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The bot's guess on the issue is right. The models catalog now gives every opencode and opencode-go model its own provider.api (.../openai/v1, .../anthropic/v1, .../google/v1beta). models-dev.ts turns that into the model's settings.baseURL, and ModelResolver lays model settings over provider settings, so the catalog endpoint wins. ConfigProviderPlugin already strips the model's baseURL when the config sets one on the provider, but only for models listed under that provider's models. Every other model kept the catalog endpoint, so the configured gateway never got a request.

The fix strips the catalog baseURL from every model of a provider whose config sets settings.baseURL. A baseURL set on a model in config is applied later and still wins.

One trade-off to decide on. With this, one provider baseURL sends every model to the same base, whatever API shape the model uses. For a gateway that mirrors the upstream (my test below), Claude-shaped models hit <baseURL>/messages and OpenAI ones <baseURL>/responses or /chat/completions. That matches the docs ("customize the base URL for any provider") and what listed models already do. Before the per-model endpoints, opencode-go worked this way too. It does change one setup, though: someone who sets a provider baseURL on a catalog with per-shape endpoints (zenmux, ofox, azure) and relies on the Claude-shaped models still using the catalog's /anthropic/v1. They would need a model-level baseURL for those models. If you'd rather keep per-shape endpoints, I can narrow this to models that use the provider's own package. That only half fixes the report, though: minimax-m3 and gpt-5.6-luna from the issue would still skip the gateway.

How did you verify your code works?

  • New test in packages/core/test/config/provider.test.ts: a catalog model with its own baseURL resolves to the configured provider baseURL, and a model with a configured baseURL keeps it. It fails on dev (Received: "https://catalog.example/v1").
  • Ran the bot's reproduction from source in a container with no network, with a fake gateway on 127.0.0.1 that logs requests:
    • dev: all three models fail with getaddrinfo ETIMEOUT opencode.ai, and the gateway sees nothing.
    • This branch: deepseek-v4.1-flash, minimax-m3 and gpt-5.6-luna all reach the gateway (POST /v1/chat/completions, /v1/messages, /v1/responses).
  • bun test in packages/core: 6284 pass, 24 fail. The same 24 fail on clean dev in my container (ripgrep and search tools, plus the env isolation test).
  • tsgo -b in packages/core is clean. Prettier is clean on the changed lines.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #54833, #55984

The models catalog now gives every opencode and opencode-go model its own
endpoint, and a model's settings win over its provider's when a model is
resolved. A provider-level settings.baseURL from config was only stripped
from models listed under that provider's models, so for everything else the
catalog endpoint won and the configured gateway never saw a request.

Drop the catalog endpoint from every model of a provider whose config sets
baseURL. A baseURL configured on a model still wins.
@github-actions

Copy link
Copy Markdown
Contributor

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes #56064. I ran the bot's reproduction from source with a local gateway that logs requests. On the base, deepseek-v4.1-flash, minimax-m3 and gpt-5.6-luna from opencode-go all went to opencode.ai (Invalid credential) and the gateway got nothing. With this PR, all three reach the gateway on /v1/chat/completions, /v1/messages and /v1/responses. test/config/provider.test.ts passes and typecheck in packages/core is clean.

Public API: unchanged. Only the behaviour of the existing provider settings.baseURL config key changes.

One concern before merge (inline): stripping the catalog baseURL from every model reaches further than the zenmux/ofox/azure case in the description. In the bundled catalog, azure and azure-cognitive-services have no provider-level endpoint and give their Claude and partner models per-model endpoints (.../anthropic/v1, .../models). amazon-bedrock does the same for its bedrock-mantle models, and google-vertex for its partner models. Setting a provider baseURL on these is a common, documented setup: an Azure OpenAI endpoint, or a Bedrock VPC endpoint. With this change, those models would also go to that base, which is likely the wrong API for them. I'd narrow the rule so it still fixes #56064 but leaves those setups alone.

Related: #54833, #55984

Comment thread packages/core/src/config/plugin/provider.ts Outdated
@Tarquinen
Tarquinen disabled auto-merge October 21, 2026 15:06
…r's origin

Models on another origin, or under a provider with no catalog baseURL (Azure, Bedrock, Vertex partner models), keep their own endpoint when the config sets a provider baseURL.
@Tarquinen

Copy link
Copy Markdown
Contributor

@Tarquinen Tarquinen closed this Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

baseURL ignored in recent versions

2 participants