Authoring a plugin¶
Start with owpp create¶
uvx owpp create
A wizard that scaffolds the plugin: code written here (a filter, action, event or pipe, or an installer of a tool and skills) or taken from a git repository pinned to a commit, with stubs, tests and a README ready to fill in. See creating a plugin.
Pick the function type first¶
The type decides how the function runs and whether global applies (see the table in plugin format).
- Does it change a chat request or reply, or add something to a message? Filter.
- Is it a button the user presses on a message? Action.
- Does it react to Open-WebUI itself (startup, enable, valve change), run on a schedule, or serve its own routes with no chat involved? Event. Events do not use
global. - Is it a model? Pipe.
A plugin that serves HTTP routes from a filter (Excalidraw) mounts them when the filter loads, which for a global filter is at startup. One that serves routes from an event mounts them on system.startup.completed, function.enable_started, function.updated and function.valves_updated.
Conventions every plugin follows¶
- One function class, one of
Pipe,Filter,Action,Event. - Every file imports what it uses, as ordinary Python: the libraries
from owpp.lib import ...,shared.py's namesfrom shared import ...(bundling). - Header in the manifest, not in the code, for code that lives in the repo. Keep long text in a comment, not the header.
- Valves are
UPPER_SNAKE, each with a description (owpp checkwarns about one without). A sync-style event hasENABLEandSYNC_INTERVAL_MINUTES(default 60, 0 = only on events) and subclassesPluginScheduledSync. - Use the libraries, do not copy them. Routes go through
plugin_mount, repeating work throughplugin_every/PluginScheduledSync, per-chat data throughchat_data, static files throughstatic/, pages it renders throughtemplates/, "am I still enabled" throughplugin_is_active, stored valves throughplugin_stored_valves. - One page means one file. A page that is just a file, with its assets, goes in
static/(index at<prefix>/). A page that needs per-request data or a per-resource check is a file intemplates/, which the function reads withplugin_template_text()and renders behind a guarded route; it is never served raw. HTML does not live in Python strings. - Handle events with
@on.include: [events],class Event(PluginEvents)and@on("function.valves_updated", own=True)on a method, not anevent()ofif __event_name__checks;owpp checkcatches a mistyped event name. - Stop when disabled. Routes answer 404 (the
plugin_mountguard), jobs stop by themselves, installed tools and skills are removed by the runtime. - Own only what you made. Mark what a sync writes (
managed_by) and touch only that. - Log with a fixed prefix (
"My Plugin: ...") so a plugin's lines can be found. - Public is deliberate. Every route needs a signed-in user. Mount with
plugin_mount, which enforces that,static/files included, and mark a route that exposes other users' datauser: PluginAdmin. Serving people who are not signed in takesaccess="public"on a mount of its own (orstatic: {access: public}), in those exact words;owpp checklists each one, so keep them few. An admin route is marked on the handler:async def purge(user: PluginAdmin); a mount where every route is admin-only usesplugin_mount(..., access="admin"); the static files usestatic: {access: admin}. A route about one chat takeschat_id: WritableChatorReadableChat, which checks that this user can reach that chat. Whatever those cannot express is still the function's, using theuserit is given. - Third-party code is pinned by full commit SHA and reviewed before the SHA moves (
owpp pullmoves it; you review and commit).
Steps¶
owpp create(orowpp init <id> --type event|filter|action|pipe, or writeplugins/<id>/plugin.yamlwith afunction:section andfunction.pyby hand).- Add
tool.py,shared.py,skills/,static/,templates/orinclude:only when needed. owpp check <id>until it is clean.- Add tests (writing a test: through the mock, or
plugin_source()for pure logic; keep Open-WebUI imports inside the functions that use them) and note any live checks in the README. - Write the README (below).
owpp initstarts one with the required sections. owpp deploy --only <id> --dry-run, then deploy (or merge, if CI deploys).
Documentation: the README every plugin has¶
Required headings (owpp init writes them; add a test like the example repo's if you want them enforced):
- A description: what it does, which libraries it uses, what it changes in Open-WebUI.
- Settings: valves and any environment variable or external setup the deploy cannot do. A plugin that shows a page in the Artifacts panel states that it needs iframe Sandbox Allow Same Origin, and what that costs (libraries).
## Test: how to check it offline (owpp check <id>,owpp bundle <id>), what your tests cover, and the steps to verify it on a live Open-WebUI.## Deploy: its function type, how it gets deployed (CI on merge, orowpp deploy --only <id>), and prerequisites.
For a plugin taken from git, also say where it comes from, the pinned commit, and how to review an upgrade.
Checklist¶
- [ ] exactly one function class;
globalonly on a filter or action - [ ] header keys in
plugin.yaml, one line each - [ ] libraries via
include:andfrom owpp.lib import ..., no pasted copies - [ ] every file imports what it uses
- [ ] disabling the function stops its routes and jobs
- [ ]
owpp check <id>passes - [ ] README has Test and Deploy sections
- [ ] data-exposing routes are gated
- [ ] a page in the Artifacts panel: README states the same-origin requirement and its cost
- [ ] remote code pinned to a full SHA
- [ ] a change has a new version (
owpp version <id> patch, and a CHANGELOG.md entry);owpp check --since origin/mainpasses