# Task Plugin API v1 Task Plugin v1 has two independent entry surfaces. `meta.routes` registers plugin-owned native URLs; `meta.protocols` claims host-owned protocols without registering or copying their URLs. `apiVersion` remains `1`. A plugin may also, or instead, relay ordinary API requests on a type-61 channel and manage that channel's credentials. See Provider part. A plugin may also, or instead, inspect and change ordinary API requests on their way upstream, on any channel. See Request processing part. Protocol names lists the request formats hooks see, by the same names on every host. Host-specific members lists what only a gateway with channels, user groups and several users, such as new-api, provides; a plugin meant for other hosts too checks those members before using them. ## Manifest ```js export const meta = { apiVersion: 1, key: "vendor", name: "Vendor", version: "1.0.0", author: {name: "Author"}, description: {en: "Video generation via the vendor API", zh: "通过厂商接口生成视频"}, models: ["vendor-model"], fetchMode: "per_task", routes: [ {method: "POST", path: "/vendor/v1/jobs", type: "submit", decode: "createJob", render: "jobCreated"}, {method: "GET", path: "/vendor/v1/jobs/:task_id", type: "query", render: "jobStatus"}, ], protocols: [{name: "openai_responses", supports: ["stream", "sync", "background"]}, "openai_video"], }; ``` `submit` and `dynamic` routes require `decode` and `render`. `query` routes require `render`, prohibit `decode`, and use `taskIdParam` (default `task_id`): the path parameter of that name, or, when the path has none, the query-string parameter of that name, as MiniMax's `GET /v1/query/video_generation?task_id=` reads it. Names refer only to callable members of `native`. A plugin's routes, with the `/{key}` addresses below, must differ in method or normalized path shape; the route index is published atomically with its plugin generation. A plugin declares its vendor's own paths. The gateway serves each route at that path and again under `/{key}`: doubao's `POST /api/v3/contents/generations/tasks` is also `POST /doubao/api/v3/contents/generations/tasks`, which reaches doubao alone. A route whose first segment is the key, or a proper prefix of it, is already the plugin's own address and gets no copy: alibaba's `/ali/...`, sunoapi's `/suno/...`, `/hailuo/...` for hailuo. The own prefixes of the built-in plugins are protected: another plugin may not take one as its key, and its top-level routes under one are not served. Several plugins may declare the same method and path shape, for the same model as well. Every plugin declaring a `submit` path decodes the request, in ascending key order; the first that accepts it names the model, the others that accept the same model stay candidates, and the selected channel decides which plugin executes, as on a shared host protocol, billing the task at that plugin's `::` expression. A decoder's `model` is matched as on the host protocols: a case variant stands for the declared model and the task takes the declared spelling; an alias that an enabled channel lists and maps through `model_mapping` stays the task's model, and the driver reads the mapped name from `ctx.upstreamModel`. A single candidate's rejection reaches the client as it is; when all of several reject, the client gets each message prefixed with the plugin keys that gave it. A `query` path answers through the task's own plugin, the first in key order owning it; a task none of them owns is not found, like a missing one. A `dynamic` path answers a query through the first plugin owning the tasks and otherwise continues as a submit. Each plugin reads the path parameters under the names it declares, so `/v1/videos/:request_id` and `/v1/videos/:task_id` share a path. A catch-all (`*name`) beside another plugin's literal segment at the same position cannot be served together; the gateway then excludes one plugin with a routing error. Routes stay out of the reserved namespaces `/v1/tasks`, `/assets` and the console pages, and a key may not be `api` or the first segment of one of them: such a plugin fails to compile. Every plugin, built-in or uploaded, is served at its top-level paths, such as `POST /v1/systemone`, except where a host route of the same method, or the trailing-slash redirect it causes, answers first, or where the first segment is another plugin's key or a built-in plugin's own prefix. Such a route is still served under `/{key}`, and the plugin list (`GET /api/plugin/task`) and detail name it in `skipped_routes` (`"GET /v1/models"`). A plugin whose key is `api`, the first segment of a host route (`v1`, `v1beta`, `mj`, `pg`, `dashboard`) or a built-in plugin's own prefix is excluded with a routing error. A `query` route's task-id parameter only receives gateway task ids, so it never meets a literal host segment: `GET /v1/videos/text2video/:task_id` is free beside the host's `GET /v1/videos/:task_id/content`. Two host routes offer matching requests to plugin routes first, so plugin routes may overlap them. `GET /v1/videos/:task_id` answers through the task's own plugin when the task was submitted on one of that plugin's native routes (at the vendor path, under `/{key}` or under its own prefix) and the plugin serves a `query` route matching the request; every other task gets the OpenAI video object. `POST /v1beta/models/{model}:predictLongRunning` goes to the matching plugin route before the Gemini relay's authentication, rate limit and channel selection; other Gemini actions, and requests no plugin route matches, stay with the relay. `routes[].retainResult` is an optional boolean on `submit` and `dynamic` routes, default `true`. Declare `retainResult: false` only on routes where every successful submission completes immediately (`parseSubmitResponse` returns a terminal `immediate`), typically a vendor's synchronous image API that has no task to re-query. The host omits `task.data` from storage for an immediate terminal result. Later lookups return task not found on the plugin's `query` routes, `GET /v1/responses/:response_id`, `GET /v1/videos/:task_id`, video content, and artifact listing and content. The task row remains for billing and the task log. The submit presenter receives the complete in-memory `task.data`, and `extractUsageOnComplete` runs before persistence. If a declaring route returns an asynchronous result, the host stores it for retrieval and logs a warning. `query` routes reject the field. Older API v1 hosts reject it as an unknown field. `openai_image` also delivers immediate terminal results inline. On this protocol and native routes with `retainResult: false`, the submit reply, each SSE event and the `taskData` of an immediate terminal result may be as large as `MAX_FILE_DOWNLOAD_MB` (default 64 MiB). The host keeps a discarded result's snapshot and result URL in memory for the submit call, so a vendor can return Base64 images inline. Retained submit `taskData` and plugin `state` each have a 1 MiB limit. An `openai_image` task completed by in-request polling keeps the snapshot the poller wrote. `openai_responses` and `openai_video` retain their results for host artifact URLs. Plugins can return compact `taskData` from `parseSubmitResponse` to store a preview. `routes[].models` optionally restricts a `submit` or `dynamic` route to a subset of `meta.models`. The host matches the canonical top-level `model` body field before any JS hook runs, counting a case variant or a channel alias of a listed model as listed; a missing, non-string, or unlisted model is rejected with 400 (plugin routes are exclusive paths, so there is no relay fallback). Declare it only when the model lives at the body top level — vendor formats that nest the model elsewhere should omit `models` and filter inside `decode`. `query` routes have no body and reject the field. Each `protocols` entry claims a host protocol. A protocol that defines modes must be claimed in object form with an explicit `supports`; the bare-string form is valid only for protocols without modes (`openai_video`, `openai_image`). `supports` declares which client request forms the plugin accepts on `openai_responses`: `"stream"` (`stream: true`), `"sync"` (neither flag; the call blocks until the terminal Response), `"background"` (`background: true`; the create returns a pending Response immediately). An unsupported request form is rejected with a 400 at channel selection, before any plugin hook runs and before billing. Retrieval (`GET /v1/responses/:response_id`) is not a mode: every created response is always retrievable. `{name, models}` still narrows that protocol's endpoint bindings to a subset of `meta.models` and composes with `supports`. Unlisted models never enter the plugin on that protocol path — they fall through to the built-in Go relay. Multiple plugins may claim the same model on the same host protocol path, including type-61 plugins and plugins with legacy `channelTypes`. Candidates are ordered by ascending plugin key. The selected channel determines the executing plugin: the candidates declaring its channel type for legacy channels, `setting.task_plugin_key` for type-61 channels, or the bound entry of `setting.task_plugin_key` / `setting.task_extend_plugin_keys` for type-60 New API channels. A type-60 channel is extended with any number of plugins because the upstream gateway may host many, and a legacy channel type may be declared by several plugins; when several candidates a channel serves share the model, the first in ascending key order executes, independent of which candidate an earlier attempt pinned. Every change that puts a plugin into service pre-flights that plugin against the live routing generation: an upload with `enabled: true` (the default), switching a plugin on, activating a version (activation also switches it on), deleting the active version when another stored version or the factory built-in takes over the key, and uploading the serving version again with `enabled: false` when the factory built-in takes over. A model name that differs from another plugin's only in case, or another protocol on the same host path and model, rejects the change and leaves everything as it was (the error names the counterpart plugin); `force` does not bypass the check. Sharing a model on the same host protocol, or a native path, is allowed. An upload with `enabled: false` still stores a conflicting plugin, and switching it on is rejected while its counterpart is enabled. To replace a plugin, switch the old one off first. `endpoints`, `routes[].renderer`, global `resolveRequest`, global `renderError`, and global `renderers` are rejected. `parseSubmitResponse` returns only `{taskId, taskData, immediate?, state?}`; `clientResponse` is rejected. `icon` is an optional LobeHub icon name string (for example `Sora.Color`). The values `text` and `text: