Skip to content

Cannot load custom providers from local file paths #4324

Closed

Description

@sredfern

Description

OpenCode fails to load custom providers when using local file paths, always attempting to install them from npm registry instead. This prevents important use cases like local development, private/internal providers, and custom integrations.

Current Behavior

When configuring a custom provider with a local path:

{
  "provider": {
    "my-custom-provider": {
      "name": "My Custom Provider",
      "npm": "/path/to/my-provider",
      "models": {
        "custom-model": { "name": "Custom Model" }
      }
    }
  }
}

OpenCode attempts to install it via npm:

bun add --force --exact /path/to/my-provider@latest

This fails with:

ProviderInitError: ProviderInitError
  data: {
    providerId: "my-custom-provider"
  }

BunInstallFailedError: BunInstallFailedError
  data: {
    pkg: "/path/to/my-provider",
    version: "latest"
  }

What could work:

OpenCode should detect local file paths and import them directly without attempting npm installation, similar to how other configuration options (like plugins and tools) support local paths.

Expected to work:

  • Absolute paths: "/path/to/provider"
  • Relative paths: "./providers/my-provider"
  • File URLs: "file://./providers/my-provider"

what problems does this cause?

I'm trying to use opencode as a harness for generating information using llm's. We have a custom llm gateway that we use to handle all of the auth around different models. However, I'm unable to use the AI SDK as I cant make my own custom provider.

I've submitted PR #4323 with a proposed fix for this issue.

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. rekram1-node commented on Nov 14, 2025

    @rekram1-node
    Collaborator

    fixed by U

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions