Skip to content

[BUG] Custom provider initialization fails with "fn3 is not a function #7792

Closed as not planned

Description

@boyan250422-code

Description

Description

Attempting to use a custom provider configuration results in a TypeError: fn3 is not a function during provider initialization. The custom provider feature appears to be incomplete or has compatibility issues.

Reproduction Steps

  1. Add the following to opencode.json:
{
  "provider": {
    "custom": {
      "api": "openai",
      "options": {
        "apiKey": "xxx",
        "baseURL": "http://localhost:8045/v1"
      },
      "models": { ... }
    }
  }
}
  1. Run opencode run "hello" --model custom/model-name
  2. Error occurs during provider initialization

Error Message

ProviderInitError: ProviderInitError
data: { providerID: "custom" }

TypeError: fn3 is not a function

Environment

  • OS: Windows 11
  • opencode version: v1.0.150 (also affects v1.0.210)
  • oh-my-opencode version: v2.14.0

Root Cause

opencode attempts to dynamically load a custom provider module but cannot find the corresponding create* function. The custom provider functionality is either incomplete or has compatibility issues.

Workaround

Use built-in provider with overridden options:

{
  "provider": {
    "anthropic": {
      "options": {
        "apiKey": "your-api-key",
        "baseURL": "http://localhost:8045/v1"
      }
    }
  },
  "model": "anthropic/claude-sonnet-4-5"
}

Expected Behavior

Custom provider should initialize correctly according to the configuration.

Additional Notes

This workaround works for most use cases but limits flexibility when users truly need custom provider definitions.

Plugins

No response

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. github-actions commented on Jan 11, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    These issues all relate to custom provider configuration failures, particularly with @ai-sdk/openai-compatible and other providers. Some report similar 'fnX is not a function' errors during provider initialization, while others report related configuration issues with custom providers.

    Feel free to ignore if none of these address your specific case.

  2. adilovcode commented on Jan 12, 2026

    @adilovcode

    Any updates on this ?

  3. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  4. yuhuoji commented on Apr 27, 2026

    @yuhuoji

    same error

    {ast login: Mon Apr 27 20:49:18 on console
      "name": "UnknownError",ir ~ % opencode
      "data": {
        "message": "TypeError: fn3 is not a function. (In 'fn3(input)', 'fn3' is an instance of Object)\n    at <anonymous> (src/plugin/index.ts:87:28)\n    at processTicksAndRejections (native:7:39)"
      }
    }
    
  5. viper968 commented on Apr 30, 2026

    @viper968

    same error on most recent version as of posting this with no custom model config afaik, running on void linux:

    {
      "name": "UnknownError",
      "data": {
        "message": "TypeError: fn3 is not a function. (In 'fn3(input)', 'fn3' is an instance of Object)\n    at <anonymous> (src/plugin/index.ts:87:28)\n    at processTicksAndRejections (native:7:39)"
      }
    }
    
  6. adilovcode commented on Apr 30, 2026

    @adilovcode

    I forgot to post why it was happening for me. I had custom plugin which was exporting some objects along with main plugin function.
    I looked at their plugin implementation and figured out.

  7. viper968 commented on May 6, 2026

    @viper968

    I forgot to post why it was happening for me. I had custom plugin which was exporting some objects along with main plugin function. I looked at their plugin implementation and figured out.

    The only plugin I have is an old version of ohmyopencode back when it had to be installed via npm/npx, could you please provide a sort of "guide" on where to find plugins, what to search for inside a plugin, and what to do to fix the issue if what you did fixed the fn issue

  8. Jayzhang1995 commented on Jun 9, 2026

    @Jayzhang1995

    remove "oh-my-opencode" plugin config work for me ,
    vim ~/.config/opencode/opencode.json,
    "plugin": ["oh-my-opencode", "opencode-antigravity-auth@1.3.1"],

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