Skip to content

Configured credentialless providers require an empty API key #42790

Closed

Description

@thdxr

Description

In V2, Catalog.provider.available() treats any string-valued settings.apiKey, including an empty string, as an enablement signal. A provider explicitly added through config can therefore remain unavailable when it has no active Integration connection unless users set apiKey: "". The resolver then also interprets that empty value as a request to suppress native provider authentication.

Provider activation should be modeled independently from credentials. Configured providers should be explicitly enabled, automatic providers should derive availability from Integration state, and disabled providers should remain unavailable. For explicitly enabled API-key routes with no resolved or configured credential, Core should use Auth.none without replacing provider-owned auth such as Bedrock SigV4.

Steps to reproduce

  1. Configure a custom Google or xAI gateway with a baseURL and custom authentication header.
  2. Do not configure a provider API key or active Integration credential.
  3. Observe that the provider is absent unless settings.apiKey is set to an empty string.

Plugins

None

OpenCode version

V2 development branch

Activity

  1. kvnloo commented on Sep 15, 2026

    @kvnloo

    Re-checked on current dev (e03db9b).

    Still broken:

    1. Catalog.provider.available treats any string request.body.apiKey as an enablement signal, including "". An integration-backed provider with custom baseURL/headers and no credential stays unavailable unless you set apiKey: "".
    2. That empty string then goes through SessionRunnerModel’s apiKey() as Auth.value(""), which fails with missing credential instead of Auth.none (omitting the key is fine).

    Live: unit repro on this HEAD — (a) no apiKey → absent from provider.available(), (b) apiKey: "" → present, (c) empty key auth apply → Failure, (d) omitted key → Auth.none.

    Prior #44418 never landed and targeted the old aisdk-native mapper. On this tree the leaf is:

    • packages/core/src/catalog.ts (typeof … === "string")
    • packages/core/src/session/runner/model.ts (apiKey() empty → Auth.value)

    Happy to send a tiny issue-linked fix treating "" as unset in both places if that’s wanted.

  2. opencodejr commented on Oct 28, 2026

    @opencodejr

    Thanks for the report. I couldn't reproduce this on v2.2.0, the latest release, since the issue doesn't give a version number.

    What I tried:

    • No provider API key, no env vars and no Integration connection.
    • A config entry for xai and one for google, each with only settings.baseURL and a custom header (no apiKey).

    What happened:

    • opencode models listed both providers without apiKey: "". Without the config entry, neither was listed.
    • opencode run sent requests without credentials, so native auth was skipped without an empty key.

    The current dev code (ced73dc0f) already models this the way you describe:

    • Configured providers get activation: "enabled".
    • auto providers derive availability from Integration state.
    • disabled providers stay unavailable.
    • ModelResolver falls back to Auth.none only for enabled API-key packages that have no resolved or configured credential, so provider-owned auth like Bedrock SigV4 is left alone.

    If you still see the provider missing, the exact commit or version and the config you used would help.

    Separately, my requests went to the real xAI/Google endpoints, not the mock server at the configured baseURL. I didn't check whether that's a bug or a mistake in my config.

  3. Tarquinen commented on Nov 2, 2026

    @Tarquinen
    Member

    This was fixed by #60770: providers that don't need credentials can now set apiKey: false. It will ship in the next release. Closing this issue.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions