Skip to content

OpenCode 2 plugin API compatibility #31

Closed

Description

@kenchrcum

What problem are you trying to solve?

The current plugin uses OpenCode 1’s plugin API, including @opencode-ai/plugin, the V1-style plugin function export, and config/event hooks. OpenCode 2 introduced a breaking plugin API, so the plugin does not load or function correctly in OpenCode 2 even when the configuration is updated from plugin to plugins.

This prevents OpenCode 2 users from using the plugin’s LiteLLM model discovery, metadata enrichment, authentication, filtering, and caching features.

Proposed solution

Port the plugin to the OpenCode 2 plugin API while preserving its existing functionality.

The implementation should use OpenCode 2’s Plugin.define({ id, setup }) entry point, register LiteLLM providers and discovered models through ctx.provider.transform(), refresh them with ctx.provider.reload(), and replace the V1 event hook with ctx.event.subscribe().

The existing LiteLLM API, model formatting, filtering, capability overrides, authentication, pricing, reasoning variants, and cache utilities could be reused. Ideally, the package should support both OpenCode 1 and OpenCode 2 during a transition period; otherwise, the OpenCode 2 support could be released as a new major version with updated documentation and configuration examples.

Alternatives considered

None

Scope check

  • My request is related to LiteLLM model discovery, configuration, or routing

Activity

  1. MathisHammel commented on Sep 23, 2026

    @MathisHammel

    Seconding this. As of today, OpenCode v2 is now the default version on the download page so this plugin is now incompatible with the official release.

  2. yuseferi commented on Sep 24, 2026

    @yuseferi
    Owner

    Sharing some empirical runtime findings that bear on this issue (and on #32), from probe plugins run under opencode models --print-logs --log-level DEBUG and opencode debug v2 on two real runtimes.

    Loader contract (verified):

    • Stable 1.18.31 and the newest dev build (0.0.0-dev-202609221946) both use the V1 loader only. A plugin loads when its default export is an object with a server() method, or when it exposes a named function export.
    • A default export shaped { id, setup } with no server() is rejected outright with must default export an object with server(). setup is never invoked and catalog.transform never fires on either runtime — opencode debug v2 shows the V2 catalog present but empty (providers: []).

    Implication for the "support both during a transition" question:
    It's feasible in a single release, and the way to do it is a hybrid default export — one object carrying both a V1 server() and the V2 Plugin.define({ id, setup }) shape. The loader calls server() today; the V2 setup stays inert and activates automatically if/when upstream wires the V2 loader. No major-version split is required just to keep V1 working.

    On the API surface: the older @opencode-ai/plugin/v2/promise CatalogDraft only exposes update/remove (no model add) and its setup isn't called by any shipping runtime, so it can't implement the ctx.provider.transform() + newly-registered-models design described above. @opencode/plugin@2.x (the surface #32 targets) does have provider.transform, editor.add, and event.subscribe, so that's the correct package for the design this issue asks for.

    PR #32's default export ({ ...Plugin.define(...), async server(input) { return LiteLLMPlugin(input) } }) matches the verified loader contract: it loads today via server() and carries the V2 path forward. Details in my comment there.

  3. yuseferi commented on Sep 29, 2026

    @yuseferi
    Owner

    Resolved by #32, merged on 2026-09-29. The plugin now supports OpenCode V2 natively while preserving the OpenCode 1.18.29+ server entrypoint. Closing this issue.

  4. mrivnak1 commented on Sep 29, 2026

    @mrivnak1

    > **RFC status:** OpenCode 2 support is not yet included in the published npm

    Why is it not published in the NPM package? In that case can you say v2 is actually supported?

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

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions