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

Open
opened 2026-02-16 17:45:12 -05:00 by yindo · 2 comments
Owner

Originally created by @boyan250422-code on GitHub (Jan 11, 2026).

Originally assigned to: @rekram1-node on GitHub.

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

Originally created by @boyan250422-code on GitHub (Jan 11, 2026). Originally assigned to: @rekram1-node on GitHub. ### 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`: ```json { "provider": { "custom": { "api": "openai", "options": { "apiKey": "xxx", "baseURL": "http://localhost:8045/v1" }, "models": { ... } } } } ``` 2. Run `opencode run "hello" --model custom/model-name` 3. 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:** ```json { "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_
yindo added the windowsbug labels 2026-02-16 17:45:12 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 11, 2026):

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

  • #5674: Custom OpenAI-compatible provider options not being passed to API calls
  • #5210: Custom OpenAI-compatible provider returns no text content
  • #1555: LM Studio Missing as Provider, custom provider for LM Studio non-functional
  • #4862: Ollama provider initialization fails with 'fn2 is not a function'
  • #7791: Schema.ref 'QuestionInfo' was set alongside unsupported fields in v1.1.x

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.

@github-actions[bot] commented on GitHub (Jan 11, 2026): This issue might be a duplicate of existing issues. Please check: - #5674: Custom OpenAI-compatible provider options not being passed to API calls - #5210: Custom OpenAI-compatible provider returns no text content - #1555: LM Studio Missing as Provider, custom provider for LM Studio non-functional - #4862: Ollama provider initialization fails with 'fn2 is not a function' - #7791: Schema.ref 'QuestionInfo' was set alongside unsupported fields in v1.1.x 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.
Author
Owner

@adilovcode commented on GitHub (Jan 12, 2026):

Any updates on this ?

@adilovcode commented on GitHub (Jan 12, 2026): Any updates on this ?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4734