Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
draw: an OpenAI-compatible plugin's image models draw (SenseNova's sensenova-u1.5-lite)
yetone2b0387574e46
diff --git a/docs/subsystems/provider-plugins.md b/docs/subsystems/provider-plugins.mdindex c88dd199c..f5eadebdd 100644--- a/docs/subsystems/provider-plugins.md+++ b/docs/subsystems/provider-plugins.md@@ -74,6 +74,8 @@ The provider's editor lists them under *Plugin options* (`pluginOptionsField` inA plugin in front of Anthropic's or OpenAI's own API (a CPA or sub2api relay, say) can say its upstream answers a web search tool by itself (#2027). Its `config` hook sets `searches: true` on the provider; the host passes it through (`plugin.Provider.Searches`), and [`pluginProvider`](../../internal/provider/plugins.go) sets the provider's `Searches`, as a custom provider's "Searches the web by itself" does (#359). [`searchesItself`](../../internal/gateway/search.go) honours it for a plugin's provider only, on Anthropic's or Responses' API, and only for one the plugin has a model on: a client's `web_search` then goes to the plugin's `fetch` as sent, not through magpie's search. Another sign-in's `Searches` is never read, and Codex's and Grok's stay as they were. As with a relay, `searchRank` leaves it out, so magpie never picks it to search for other models; Settings can name it by hand (`namedSearcherRank`).+A plugin in front of an OpenAI-compatible API draws with the image models its list names (01huadalang on Discord: the SenseNova plugin, aqiu817/magpie-sensenova, lists `sensenova-u1.5-lite` from `token.sensenova.cn/v1/models`). [`Drawers`](../../internal/gateway/draw.go) lists a plugin provider's model for Settings' image generation picker when its id is an images-API model (`catalog.DrawsID` and `catalog.ImagesAPI`) and the plugin speaks it on `@ai-sdk/openai-compatible` (`Provider.PluginOpenAICompatible`); `drawImages` sends it to `/v1/images/generations` or `/v1/images/edits` under the plugin's base, through its `fetch`, which signs it as a chat. A model on another package (Anthropic's, a vendor's own API such as Cursor's) isn't listed, as no images API sits under that base. Grok's and WorkBuddy's plugins keep their own drawers. `TestSenseNovaPluginDraws`.+A plugin can instead mark single models of its list with `searches: true` (on the `config` hook's model or the `models` hook's list): a model that searches the web by itself when asked in plain words, such as Trae's search model. The host passes it through (`plugin.Model.Searches`), `pluginCatalog` makes it the catalog model's `WebSearch` "native", and the gateway offers the provider in Settings › Web search's picker and its own pick with those models alone (`pluginSearches`, `partSearcher`).## A plugin's service tiersdiff --git a/internal/gateway/draw.go b/internal/gateway/draw.goindex bef343e53..52a2a949c 100644--- a/internal/gateway/draw.go+++ b/internal/gateway/draw.go@@ -255,6 +255,20 @@ func Drawers(p provider.Provider) []catalog.Model {}return out}+ if p.IsPlugin() {+ // a plugin in front of an OpenAI-compatible API: the image models+ // its list names that draw on the images API, sent through its+ // fetch under the base its chat goes to (01huadalang on Discord:+ // the SenseNova plugin's sensenova-u1.5-lite)+ var out []catalog.Model+ for _, m := range p.Available() {+ if catalog.DrawsID(m.ID) && catalog.ImagesAPI(m.ID) && p.PluginOpenAICompatible(m.ID) && p.ModelKind(m.ID) != provider.KindVideo {+ m.Provider = p.ID+ out = append(out, m)+ }+ }+ return out+ }// any other subscription is asked through its agent's own API, which// draws nothing magpie can ask for yet. A Responses-only relay (a Codex// backend such as sub2api) has no chat base but serves the images APIdiff --git a/internal/gateway/draw_sensenova_test.go b/internal/gateway/draw_sensenova_test.goindex e775a4f73..024664108 100644--- a/internal/gateway/draw_sensenova_test.go+++ b/internal/gateway/draw_sensenova_test.go@@ -118,3 +118,53 @@ func TestSenseNovaU1Draws(t *testing.T) {t.Fatalf("edit was sent %v", sent)}}++// The SenseNova plugin (aqiu817/magpie-sensenova), in front of+// token.sensenova.cn/v1 on @ai-sdk/openai-compatible, lists+// sensenova-u1.5-lite from SenseNova's /models: Settings' image+// generation picker lists it, and it draws and edits on SenseNova's images+// API through the plugin's fetch, in the shape TestSenseNovaU1Draws holds+// a key to. An image model the plugin speaks on another vendor's package+// isn't listed, as no images API sits under its base (01huadalang on+// Discord).+func TestSenseNovaPluginDraws(t *testing.T) {+ t.Setenv("FAKE_SENSENOVA", "1")+ v := &senseNova{}+ pid := besideFake(t, "sensenova", v)+ p, err := provider.Find(pid)+ if err != nil {+ t.Fatal(err)+ }+ var drawers []string+ for _, m := range Drawers(*p) {+ if m.Provider != pid {+ t.Fatalf("drawer %s of %q", m.ID, m.Provider)+ }+ drawers = append(drawers, m.ID)+ }+ if !slices.Equal(drawers, []string{"sensenova-u1.5-lite"}) {+ t.Fatalf("drawers %v, want sensenova-u1.5-lite alone", drawers)+ }+ s := New()+ code, a, raw := postImages(t, s, "/v1/images/generations", "application/json", `{"model":"`+pid+`/sensenova-u1.5-lite","prompt":"a magpie","size":"1024x1024"}`)+ if code != 200 || len(a.Data) != 1 {+ t.Fatalf("%d %s", code, raw)+ }+ if b, _ := base64.StdEncoding.DecodeString(a.Data[0].B64); string(b) != string(pngBytes) {+ t.Fatalf("image %q", b)+ }+ if sent := v.got("/v1/images/generations"); len(sent) != 1 || !strings.Contains(sent[0], `"model":"sensenova-u1.5-lite"`) || !strings.Contains(sent[0], `"response_format":"b64_json"`) {+ t.Fatalf("generation was sent %v", sent)+ }+ if sent := v.got("/v1/chat/completions"); len(sent) != 0 {+ t.Fatalf("an image model was asked on chat: %v", sent)+ }+ img := "data:image/png;base64," + base64.StdEncoding.EncodeToString(pngBytes)+ code, a, raw = postImages(t, s, "/v1/images/edits", "application/json", `{"model":"`+pid+`/sensenova-u1.5-lite","prompt":"bluer","images":[{"image_url":"`+img+`"}]}`)+ if code != 200 || len(a.Data) != 1 {+ t.Fatalf("edit: %d %s", code, raw)+ }+ if sent := v.got("/v1/images/edits"); len(sent) != 1 || !strings.Contains(sent[0], `"images":[{"image_url":"data:image/png;base64,`) {+ t.Fatalf("edit was sent %v", sent)+ }+}diff --git a/internal/plugin/testdata/fake/index.js b/internal/plugin/testdata/fake/index.jsindex 8cc085d2a..3796dda35 100644--- a/internal/plugin/testdata/fake/index.js+++ b/internal/plugin/testdata/fake/index.js@@ -85,6 +85,14 @@ export const FakePlugin = async ({ client }) => ({if (process.env.FAKE_RESPONSES) cfg.provider[ID].models["fake-resp"] = { name: "Fake Responses", provider: { npm: "@ai-sdk/openai" }, limit: { context: 4000, output: 400 } }// $FAKE_GROK: a Grok model on Responses, as Grok's plugin serves itif (process.env.FAKE_GROK) cfg.provider[ID].models["grok-4.7"] = { name: "Grok 4.7", provider: { npm: "@ai-sdk/openai" }, limit: { context: 4000, output: 400 } }+ // $FAKE_SENSENOVA: SenseNova's image model as its plugin lists it from+ // token.sensenova.cn/v1/models, on the provider's openai-compatible;+ // and an image model on a vendor's own API (Anthropic's package), which+ // no images API of the base serves+ if (process.env.FAKE_SENSENOVA) {+ cfg.provider[ID].models["sensenova-u1.5-lite"] = { name: "sensenova-u1.5-lite", limit: { context: 131072, output: 32768 } }+ cfg.provider[ID].models["flux-2"] = { name: "Flux 2", provider: { npm: "@ai-sdk/anthropic" }, limit: { context: 1000, output: 100 } }+ }// $FAKE_DEEPSEEK: a DeepSeek model, as Cline's cline-pass/deepseek-v4-proif (process.env.FAKE_DEEPSEEK) cfg.provider[ID].models["deepseek-v4-pro"] = { name: "DeepSeek V4 Pro", limit: { context: 1000, output: 100 } }// $FAKE_GLM: a GLM model, as Cline's cline-pass/glm-5.3diff --git a/internal/provider/plugins.go b/internal/provider/plugins.goindex 165a206c8..b34e54323 100644--- a/internal/provider/plugins.go+++ b/internal/provider/plugins.go@@ -97,6 +97,23 @@ func (p Provider) PluginProvider() string {return p.Account.plugin.ID}+// PluginOpenAICompatible is whether p is a plugin's provider that speaks+// model on an OpenAI-compatible API (@ai-sdk/openai-compatible), whose+// other routes, the images API among them, its fetch sends under the same+// base: SenseNova's plugin at token.sensenova.cn/v1. A plugin of a vendor+// with an API of its own (Cursor's, Kiro's) speaks another package.+func (p Provider) PluginOpenAICompatible(model string) bool {+ if !p.IsPlugin() {+ return false+ }+ pp := *p.Account.plugin+ if cur, ok := PluginOf(p.ID); ok {+ pp = cur+ }+ m, ok := pluginModel(pp, model)+ return ok && firstOf(m.NPM, pp.NPM) == "@ai-sdk/openai-compatible"+}+// PluginOf is the plugin provider magpie's provider id is, when it is one.func PluginOf(id string) (plugin.Provider, bool) {for _, pp := range heldPlugins() {