musistudio/claude-code-router · warning · Error

OpenCode CLI public models were not found.

Error message

OpenCode CLI public models were not found.

What it means

When no OpenCode credential exists (publicOnly mode), every requested model must be in the static public catalog for the protocol; if any model is missing, the import is rejected.

Source

Thrown at packages/core/src/agents/local-providers/opencode.ts:142

  });
}

export function importOpenCodeProvider(
  candidate: LocalAgentProviderCandidate,
  providerNames: string[]
): LocalAgentProviderImportResult {
  const credential = readOpenCodeCredential();
  if (credential?.hasCredential && !credential.apiKey) {
    throw new Error("OpenCode CLI API key was not found.");
  }
  const publicOnly = !credential;
  const catalog = readOpenCodeCatalog({ publicOnly });
  if (!isOpenCodeProtocol(candidate.protocol)) {
    throw new Error(`Unsupported OpenCode protocol: ${candidate.protocol}`);
  }
  const protocol = candidate.protocol;
  if (publicOnly && !candidate.models.every((model) => catalog.models[protocol].includes(model))) {
    throw new Error("OpenCode CLI public models were not found.");
  }
  const provider = providerPayload(
    candidate,
    uniqueProviderName(providerNames, candidate.name),
    catalog.baseUrl
  );
  if (publicOnly) {
    return {
      candidate,
      provider: {
        ...provider,
        apiKey: "public"
      },
      providerPlugins: []
    };
  }
  const apiKey = credential?.apiKey;
  if (!apiKey) {

View on GitHub (pinned to 99f24806c6)

Solutions

  1. Authenticate with OpenCode (`opencode auth login`) so publicOnly is false and the live catalog is used.
  2. Update the app so the public catalog includes the model.
  3. Remove the unsupported model from the candidate model list before importing.

Example fix

// before
request.models = ["new-model-x", "known-model"];
// after
request.models = ["known-model"]; // or authenticate first
Defensive patterns

Strategy: validation

Validate before calling

const missing = candidate.models.filter(m => !publicCatalog[protocol].includes(m));
if (missing.length) authenticateOrDrop(missing);

Type guard

null

Try / catch

catch (e) { if ((e as Error).message.includes('public models')) await promptOpenCodeLogin(); }

Prevention

When it happens

Trigger: importOpenCodeProvider with publicOnly=true and candidate.models containing at least one model absent from catalog.models[protocol].

Common situations: A new model shipped in OpenCode CLI but not yet in this app's bundled catalog; a user-editable config lists a custom/renamed model.

Related errors


AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27). Data as JSON: /api/errors/8c8835f96b57bdc6. Report an issue: GitHub.