Skip to content

v2: normalize or reject unprefixed AI SDK packages in native provider config #44881

Closed

Description

@rekram1-node

Problem

Native V2 provider configuration accepts an AI SDK npm package without the required aisdk: prefix, but the resulting provider fails only when a prompt is sent. This makes a plausible configuration silently select the native OpenCode provider loader instead of AI SDK compatibility.

{
  "providers": {
    "custom": {
      "package": "@ai-sdk/openai-compatible",
      "models": { "chat": {} }
    }
  }
}

The currently working form requires an undocumented/non-obvious discriminator:

{
  "providers": {
    "custom": {
      "package": "aisdk:@ai-sdk/openai-compatible",
      "models": { "chat": {} }
    }
  }
}

The same issue applies to model-level package overrides. Legacy V1 provider.*.npm and model-level provider.npm values are automatically normalized during migration, and models.dev packages are also normalized, so native V2 config behaves inconsistently with those sources.

Current implementation

  • packages/core/src/config/plugin/provider.ts copies provider-level and model-level package values directly into the catalog.
  • packages/core/src/provider.ts recognizes AI SDK packages only when prefixed with aisdk:.
  • packages/core/src/model-resolver.ts treats every unprefixed package as a native OpenCode provider module.
  • V2 provider and model config schemas currently accept the invalid-looking-but-runtime-broken bare AI SDK strings.

Expected behavior

Native V2 configuration should either normalize obvious AI SDK package names such as @ai-sdk/* at both provider and model levels, or reject them early with an actionable validation error explaining the required aisdk: prefix. The public V2 provider documentation should explain native versus AI SDK package selection.

Preserve legitimate unprefixed native provider modules and native file:// packages; arbitrary third-party AI SDK packages may still need an explicit discriminator.

Activity

  1. neriousy commented on Oct 22, 2026

    @neriousy
    Member

    Partly done in #48943: bare AI SDK package names that are in the native map (e.g. @ai-sdk/openai-compatible) are now rewritten to the native package (aisdk-native.ts). Bare @ai-sdk/* names that aren't in the map still fail only at prompt time rather than when config loads. Closing this tracker.

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

Metadata

Metadata

Assignees

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