omp packages

pi-provider-lemonade1.5.0

Pi model provider that auto-discovers models from a Lemonade Server and integrates them into Pi via the server's OpenAI-compatible API

okulev Published 4 days ago MIT ~958 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-provider-lemonade

Pi extension that turns your local Lemonade Server into a model provider. It discovers the models you downloaded on the server automatically — add a model there, and it shows up in pi's /model list. No models.json editing.

What you need

  • pi installed (verified with pi 1.7.0; on a newer pi release, streaming should still work — and if it misbehaves, see Troubleshooting for a one-line switch).
  • Lemonade Server installed and running, with at least one model downloaded:
    • Web UI / Desktop App: tick "Downloaded Only" to see what's ready.
    • CLI: lemonade list --downloaded.

Quick start

  1. Install the extension:

    pi install npm:pi-provider-lemonade
    
  2. Start pi (pi). If your Lemonade Server runs on this machine with default settings, you're done — the extension finds it on its own.

  3. In the TUI, run /model (or press ctrl-l) and pick any lemonade/… entry. Chat away.

Everyday commands

Action How
Pick a model /model in the TUI, or ctrl-l
Pick a model from the shell pi --model 'lemonade/gemma-3-4b-it-GGUF'
Cycle through all Lemonade models pi --models 'lemonade/*', then Ctrl+P
Refresh the model list after downloading new models /reload in the TUI, or pi update --models in the shell
List all discovered models with their limits pi --list-models lemonade

Notes:

  • The /model dialog refreshes the catalog in the background while it is open, so a model you just downloaded usually appears the next time you open the dialog — no /reload needed.
  • Images: models that report the vision capability accept images pasted or dragged into the prompt. (Vision models without an mmproj companion file fail on image input — a known Lemonade limitation, lemonade-sdk/lemonade#955.)
  • Thinking: models with a thinking toggle (e.g. Qwen3, gpt-oss) show pi's thinking-level selector. This is configured automatically per model family; if a specific model's toggle misbehaves, you can override it in models.json (see Fine-tuning models).

Classifier models (experimental)

Lemonade classifier models are also discovered automatically and exposed as pi classifier models. They do not appear in /model; pi reaches them from codemode scripts, extensions, and virtual models.

Experimental: classifier support, the lemonadeClassifier descriptor fields, and the classifier tools (lemonade_classifier_catalog, lemonade_fixed_classifier_labels) may change in future versions without compatibility guarantees.

Supported Lemonade classifier forms:

Mode Lemonade model pi API Notes
systemone decision models such as Laya-GGUF typesafe-system-one typed choice/score/bool questions with instructions; optional image input
zero-shot LFM2 prompt-router ONNX lemonade-classify-zero-shot labels come from the question; instructions are prefixed to the input
fixed BERT-style encoder classifiers lemonade-classify-fixed model-defined labels; choice-only unless the labels support score/bool
chat any chat model lemonade-classify-chat one chat completion per question; flexible but slower and costlier

Codemode example:

const laya = await models.getModelOfType("classifier", "lemonade", "Laya-GGUF");
const result = await models.classify(laya, {
  state: { message: "I was charged twice" },
  questions: {
    route: {
      type: "choice",
      instructions: "Which team should handle this?",
      criteria: { billing: "Billing", shipping: "Shipping" },
    },
  },
});
if (result.stopReason !== "stop") return result.errorMessage;
const route = result.answers.route;
text(`${route.choice} (${Math.round(route.confidence * 100)}%)`);

For fixed-label models, use lemonade_fixed_classifier_labels({ model }) to learn the model's label names. lemonade_classifier_catalog is available for extended descriptor information; the model list already carries the lemonadeClassifier descriptor. Both classifier tools have codemode exposure, so they are callable from scripts and extensions but are not declared in the model's tool list (no user-session tool pollution).

Classifier discovery is label-driven; classifier models are not queried through /api/show. To try classifier support, download Laya-GGUF (SystemOne), LFM2.5-Encoder-350M-Prompt-Router-ONNX (zero-shot) and openmed-privacy-filter-multilingual-v2-onnx (fixed-label) with the Lemonade app or CLI.

Image models (experimental)

Downloaded Lemonade image models are also discovered automatically and exposed as pi image models. Like classifiers, they do not appear in /model; pi reaches them from codemode scripts, extensions, and the SDK. To try image support, download LMX-Omni-5.5B-Lite with the Lemonade app or CLI: it includes both the chat-image Omni model and its SD-Turbo component as a native API image model. SD-Turbo is generation-only (no edit). For image editing, download the larger LMX-Omni-52B-Halo: its Flux-2-Klein-9B-GGUF component supports generation and editing. The image component of an Omni collection can be installed separately — download Flux-2-Klein-9B-GGUF on its own if you only need the native image model.

Experimental: image generation and editing support, the two Lemonade image APIs, and the id-based image-capability heuristics may change in future versions without compatibility guarantees. Upscaling, variations, video, and 3D are not native image models.

Image generation and editing work through two surfaces:

Lemonade model pi API Endpoints Notes
image deployment (e.g. SD-Turbo, Flux-2-Klein) lemonade-image /v1/images/generations, /v1/images/edits text-to-image; models labelled edit also accept input images
Omni collection (collection.omni) lemonade-image-chat /v1/chat/completions text and images in, text and generated images out

Codemode example:

const sd = await models.getModelOfType("image", "lemonade", "SD-Turbo");
const result = await models.generateImages(sd, {
  input: [{ type: "text", text: "a red fox in the snow, watercolor" }],
});
if (result.stopReason !== "stop") return result.errorMessage;
for (const block of result.output) if (block.type === "image") image(block);

Extensions use ctx.modelRegistry.generateImages(). The model list is ordered with chat-capable Omni collections first, then edit-capable models, then generation-only models; pinned and loaded models come first inside each group.

The generic size and aspectRatio options are mapped to Lemonade's WIDTHxHEIGHT. When size is omitted, text-to-image requests use the model's own size, else 512x512; edits use the first reference image's size, scaled down to fit the model's soft_pixel_cap (2048x2048 pixels unless the model sets one). aspectRatio alone is applied to a 1024x1024 base. Lemonade-specific options ride in metadata:

Key Meaning
n Number of images to generate. Defaults to 1; edits accept 1–10.
steps Number of inference steps; lower is faster, higher can improve quality. Defaults to the model's own setting.
cfg_scale Classifier-free guidance scale. Defaults to the model's own, else 7.0.
seed Random seed for reproducible output; a negative value picks a random seed. Defaults to the backend's fixed seed.
mask A PNG mask: white areas are edited and black areas are kept. Supply it as base64 (or a data:image/png;base64, URI) in metadata; the extension decodes it into the multipart mask file.

pi 1.7.0 codemode only forwards size/aspectRatio, so extensions and the SDK pass the metadata keys. Image input on a text-only model is routed to /v1/images/edits and the server decides whether to accept it. Request errors return an error result (stopReason: "error") and never throw.

Connecting to the server

By default the extension talks to http://127.0.0.1:13305 — the Lemonade Server's default address. If your server runs locally with defaults, skip this section entirely.

Remote or non-default server — two ways:

  1. /login lemonade in the TUI (preferred). It shows a list of known servers — the one from a previous login, the address from the environment variables (below), and any servers found by a network scan — each with a live online/offline status. Pick one (or use Scan local network…, or Enter custom URL…), then enter the API key if your server asks for one. Both are stored in pi's credential store.

  2. Environment variables. Set these before starting pi:

    Variable Default Purpose
    LEMONADE_HOST 127.0.0.1 Server host — bare host (192.168.1.100), host:port, or a full http:///https:// URL
    LEMONADE_PORT 13305 Server port (used unless LEMONADE_HOST already includes one)
    LEMONADE_API_KEY — API key sent to the server
    LEMONADE_ADMIN_API_KEY — Admin key; wins over LEMONADE_API_KEY when both are set, exactly like the lemonade CLI

A /login credential takes priority over the environment variables.

Security note: unless the server address is an https:// URL, requests — including the API key — travel unencrypted. That's fine on your own machine, but for a server on another host use an https:// URL (or a tunnel), and prefer /login lemonade over environment variables so the key isn't readable by every process in your shell.

Troubleshooting

Symptom What it means / what to do
No lemonade/… entries in /model Is the server running? Is at least one model downloaded? Then run /reload.
A model named like discovery-failed (…) The server could not be reached, or one of your models has unreadable metadata. Start the server (or fix the named model), then /reload. The error message names which models failed.
The lemonade provider appears with no models at all The server is reachable but has no usable downloaded models (every downloaded model needs completion and tools support). Download a chat model, then /reload.
Streaming breaks after a pi upgrade (missing system prompt or tools, odd request errors) Set "streamingMode": "builtin" in ~/.pi/agent/pi-provider-lemonade.json (create the file if needed) to use pi's built-in streaming, which always matches your pi version.
Startup discovery seems to fail on a server that requires an API key Normal on first launch — pi resolves the stored key lazily. Run /reload or /login lemonade once and the full catalog loads.
A request hangs forever mid-answer The extension retries rate limits and server errors automatically, but a server that stops sending without closing the connection is not timed out. Abort the turn.
Model list looks stale after a pi restart Discovery is cached in ~/.pi/agent/models-store.json for faster starts; /reload refreshes it.

Fine-tuning models

Everything numeric or model-specific can be overridden per model in ~/.pi/agent/models.json, just like for any other pi provider — no restart needed, open /model afterwards:

{
  "$schema": "https://pi.dev/schemas/models.schema.json",
  "providers": {
    "lemonade": {
      "modelOverrides": {
        "Qwen3-4B-GGUF": {
          "name": "Qwen3 4B (High Ctx)",
          "contextWindow": 131072,
          "maxTokens": 32768
        }
      }
    }
  }
}

Useful override fields: contextWindow, maxTokens, reasoning (force the thinking selector on/off), compat.thinkingFormat (how thinking controls are sent to the server — change it only if a model's toggle does nothing or the server rejects requests), input, and cost.

The extension discovers sensible defaults for all of these from the server: contextWindow from the server's model info (fallback 128,000), maxTokens 16,384 capped to what fits in the context window, cost from the server for cloud models (0 for local ones), and input: ["text", "image"] for vision models.

Extension settings (optional)

All of these have working defaults — most users never need this file. It lives at ~/.pi/agent/pi-provider-lemonade.json (or the directory in PI_CODING_AGENT_DIR):

{
  "discoveryTimeoutMs": 20000,
  "streamingMode": "extension",
  "startupScan": true
}
Key Default Purpose
discoveryTimeoutMs 20000 Total time budget for one model-discovery pass. Raise it only for very large model catalogs.
streamingMode "extension" "extension" — the extension's streaming layer (Lemonade-specific retries and error reporting); "builtin" — pi's built-in streaming (the escape hatch after a pi upgrade; see Troubleshooting).
startupScan true on Linux, false on macOS/Windows Scan the local network for Lemonade servers at startup to pre-populate the /login server list. Off by default on macOS/Windows because the scan triggers an OS firewall prompt. The manual Scan local network… in /login always works.

How model discovery works

The extension lists the server's models (GET /v1/models), asks chat candidates for their capabilities (POST /api/show), and registers chat models that support both completion and tools. Chat results are sorted: pinned models first, then loaded ones, then other downloaded local models, then unloaded cloud models. Only models with downloaded: true are included — download models with the Lemonade app or CLI, not through pi.

Classifier models are discovered separately from their /v1/models labels (classification / classifier, plus systemone or zero-shot). Classifier discovery does not use /api/show; chat-capable models also get a classifier overlay so they can be used as cross-model classifiers.

Image models are discovered from the raw /v1/models entries and their labels: image deployments become native image models, and Omni collections become chat-image models. Image discovery does not use /api/show, so it survives a chat capability probe failure. Upscaling, video, and 3D entries are not native image models.

The extension covers Lemonade's OpenAI-compatible chat, classifier, and image surfaces. Downloading models and other server features (upscaling, variations, video, 3D, audio, embeddings) are done with the Lemonade app or CLI.

Feedback and license

Bugs and feature requests: open an issue (pull requests are not accepted). License: MIT.