omp packages

@abhishek944/pi-image-gen0.14.0

Image and sprite generation for Pi, plus independent existing-image search via Serper, Brave, SerpApi, Openverse, Tavily, Parallel and OpenAI Responses.

GitHub Actions Published 23 hours ago Apache-2.0 ~2.7K 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-image-gen

Pi extension with image generation/editing (image_generate), optional sprite generation (sprite_generate), and independent existing-image search (image_search). Search has its own configuration and providers; it never generates images. See Image search below.

Supported generation providers:

Provider Model id (alias) Authentication
ChatGPT Codex gpt-image-2 on route codex-subscription (gpt-image-2-codex, codex, and openai-codex remain legacy aliases) Pi /login → ChatGPT Plus/Pro (Codex)
OpenAI gpt-image-2, gpt-image-2-2026-04-21, gpt-image-2.5-flare, gpt-image-2.5-sunburst, gpt-image-2.6-flare, gpt-image-2.6-sunburst OPENAI_API_KEY
Azure OpenAI Azure GPT Image deployment name (azure-openai-api); GPT Image 1-mini / 1.5 / 2 / 2 / snapshot / 2.5 Flare / Sunburst AZURE_OPENAI_API_KEY
Google Gemini ("Nano Banana") gemini-nano-banana-2.1 (alias nano-banana-2-1), gemini-3-pro-image (alias nano-banana-pro), gemini-3.1-flash-image (deprecated; alias nano-banana-2), gemini-3.1-flash-lite-image (alias nano-banana-2-lite), gemini-2.5-flash-image (retiring; alias nano-banana) GEMINI_API_KEY
Alibaba Model Studio (DashScope) Qwen: qwen-image-3.0-pro, qwen-image-3.0, qwen-image-2.1-pro, qwen-image-2.1-turbo, qwen-image-2.0-pro, qwen-image-2.0; Wan: wan2.7-image-pro, wan2.7-image; Z-Image: z-image-turbo DASHSCOPE_API_KEY
Volcengine Ark (ByteDance Seedream) doubao-seedream-5-5-261028 (alias seedream-5-5), doubao-seedream-5-0-pro-260628 (alias seedream-5-pro), doubao-seedream-5-0-flash-260915 (alias seedream-5-flash), doubao-seedream-5-0-260128 (aliases seedream-5, seedream), doubao-seedream-4-5-251128 (alias seedream-4-5), doubao-seedream-4-0-250828 (alias seedream-4) ARK_API_KEY
Meta Model API (Muse Image) muse-image-1.0 (aliases muse-image, meta-muse) Pi /login meta via pi-meta-oauth, or META_API_KEY
Microsoft MAI (Azure Foundry) Azure deployment name; MAI-Image-2.5 / Flash / Pro (retiring), MAI-Image-2.6 / Flash, MAI-Image-2.7 / Flash (preview) AZURE_MAI_API_KEY
OpenRouter any (use openrouter/<vendor>/<id>) OPENROUTER_API_KEY
Black Forest Labs (FLUX) FLUX.2: flux-2-pro (alias flux-2-pro-preview), flux-2-flex, flux-2-max, flux-2-klein-4b, flux-2-klein-9b (alias flux-2-klein-9b-preview); FLUX.3: flux-3-image, flux-3-image-klein BFL_API_KEY
Adobe Firefly Services firefly-image5 (aliases firefly_image, firefly-image) Client ID required (FIREFLY_SERVICES_CLIENT_ID), plus either FIREFLY_SERVICES_CLIENT_SECRET or FIREFLY_SERVICES_ACCESS_TOKEN
Stability AI stable-image-core, stable-image-ultra, sd3.5-large, sd3.5-large-turbo, sd3.5-medium — retiring 2026-12-10 STABILITY_API_KEY
Comfy (Stability compatibility) The same Stability model ids at https://stability.comfy.org COMFY_API_KEY
Ideogram ideogram-4-6 (generate and precise edit) IDEOGRAM_API_KEY
MiniMax MiniMax-H3-Image (aliases minimax-h3-image, minimax-h3), MiniMax-H3-Image-Highspeed (alias minimax-h3-image-highspeed) MINIMAX_API_KEY
Kling AI kling-image-4.0 (aliases kling, kling-4.0) KLING_API_KEY
Krea krea-3 (aliases krea, krea/krea-3) KREA_API_KEY
Together AI any (use together/<model-id>, e.g. together/black-forest-labs/FLUX.2-dev) TOGETHER_API_KEY
Cloudflare Workers AI @cf/black-forest-labs/flux-1-schnell (alias cf-flux-1-schnell); requires an account /ai/run base URL and cf-aig-gateway-id header CLOUDFLARE_API_TOKEN
Recraft recraftv4_1*, recraftv4*, recraftv3/recraftv3_vector, recraftv2/recraftv2_vector (raster and native SVG) RECRAFT_API_TOKEN
Custom providers whatever you declare in settings (your choice, via $VAR)

Upstream API docs (handy when debugging gateway behavior or adding new models):

/image-gen list annotates models with provider-published lifecycle dates and replacements. Deprecated models stay selectable for existing configurations; already-shutdown ids are removed (for example Azure gpt-image-1). Stability's image and 3D API endpoints transition to Comfy on 2026-12-10: the stability-api entries are marked retiring and keep working with an existing Stability key until that date. Add a Comfy key and switch with /image-gen use comfy-api stable-image-core (or any of the same five model ids); Stability credits do not transfer to Comfy.

Built-in API-key routes read providers.<id>.apiKey in local settings.json first, then fall back to the environment variables shown above; they do not read keys saved by Pi's general /login flow. Subscription routes are separate: Meta can use a Pi credential created by the pi-meta-oauth package, while Codex uses Pi's ChatGPT Plus/Pro login. Meta API billing also accepts META_API_KEY; legacy MODEL_API_KEY remains accepted.

For subscription-backed generation, first run /login in Pi and select ChatGPT Plus/Pro (Codex), then run /image-gen use codex-subscription gpt-image-2. No OPENAI_API_KEY is required. Codex requests use the ChatGPT-backed image endpoints and count against provider-managed subscription usage and limits. GPT Image 2.5 and 2.6 are intentionally not listed on this route: their API model ids and new controls have not been verified against the private Codex subscription endpoint.

The primary route is configured in settings.json as default: { provider, model }. Optional fallback and compare arrays contain the same provider/model pairs. image_generate uses the default with selective fallback; image_compare runs only for explicit model comparisons. Neither tool accepts arbitrary model/provider arguments. Use /image-gen use <provider> <model> to update the default safely without changing either list.

Install

From npm:

pi install npm:@abhishek944/pi-image-gen

Or directly from GitHub:

pi install git:github.com/abhishek944/pi-image-gen@v0.9.1

The package's pi.extensions field auto-registers the compiled dist/extension.js entry with the host pi-coding-agent runtime; no extra wiring needed.

Use as a Node library

The npm package ships compiled ESM JavaScript and TypeScript declarations, so a normal Node 22 process can import the library without a TypeScript loader:

import {
  generateImage,
  compareImages,
  runSpritePipeline,
} from '@abhishek944/pi-image-gen';

The package root is intentionally the lightweight library entry and does not load Pi-only runtime modules. Hosts that manually register the Pi extension instead of using the pi.extensions manifest can import its default export explicitly:

import piImageGenExtension from '@abhishek944/pi-image-gen/extension';

Configure

Settings are read by pi-shared's loadPiSettings, which merges three files (low-to-high priority):

  1. ~/.pi/agent/settings.json (global)
  2. The agent config directory's settings.json (PI_CODING_AGENT_DIR, then PI_AGENT_HOME, otherwise the global directory; duplicate paths are loaded once)
  3. <cwd>/.pi/settings.json (trusted project)

Project settings are ignored when project trust is declined. ${ENV_VAR} interpolation is supported in global and agent settings only, so keep environment-backed credentials out of project settings.

All settings live under the pi-image-gen key. New configurations should use default with an authentication-specific provider and model (the command below writes this for you):

/image-gen use gemini-api nano-banana
{
  "pi-image-gen": {
    "version": 2,
    "default": { "provider": "gemini-api", "model": "nano-banana" }
  }
}

The namespace schema version is 2, independent of the npm package version. Unversioned and version: 1 legacy configurations remain readable; unsupported versions are rejected rather than silently downgraded. Within one file, default wins over sibling legacy keys. Defaults are normalized per file before applying global < agent < trusted-project priority, so a higher legacy override still works when a lower file has already migrated. Complete defaults written by setup/use/set now contain version: 2 and default, without obsolete legacy default keys. No startup operation rewrites files automatically.

…and exports the matching env var:

export GEMINI_API_KEY=sk-...

That's it. From the agent: image_generate({ prompt: "a cyberpunk cat" }).

All settings fields

{
  "pi-image-gen": {
    "version": 2,
    "enabled": true,
    "default": { "provider": "gemini-api", "model": "nano-banana" },
    "fallback": [
      { "provider": "openai-api", "model": "gpt-image-2" }
    ],
    "compare": [
      { "provider": "gemini-api", "model": "nano-banana" },
      { "provider": "openai-api", "model": "gpt-image-2" }
    ],
    "outputDir": "var/pi-image-gen/images",
    "requestTimeoutMs": 120000,
    "openRouterDiscovery": true,
    "spriteGeneration": {
      "enabled": false,
      "defaultRows": 2,
      "defaultColumns": 3,
      "defaultFormat": "apng",
      "frameDurationMs": 120,
      "strictValidation": true,
      "outputDir": "var/pi-image-gen/sprites",
      "maxFrames": 16
    },

    "providers": {
      "openai":     { "baseUrl": "https://my-proxy.example.com/v1", "apiKey": "${MY_OPENAI_KEY}" },
      "gemini":     { "headers": { "x-goog-trace": "pi-prod" } },
      "dashscope":  { "baseUrl": "https://dashscope-intl.aliyuncs.com/api/v1" },
      "ark":        { "apiKey": "$ARK_API_KEY" },
      "meta":       { "apiKey": "$META_API_KEY" },
      "openrouter": { "apiKey": "$OPENROUTER_API_KEY" }
    },

    "customProviders": {
      "my-stable-diffusion": {
        "api": "openai",
        "baseUrl": "https://api.my-sd.example.com/v1",
        "apiKey": "${MY_SD_KEY}",
        "headers": { "x-tenant": "team-a" },
        "models": [
          { "id": "sd-3-large", "alias": "sd3" },
          "sd-3-medium"
        ]
      }
    }
  }
}
Field Purpose
version Namespace schema version. Current: 2; missing/1 are legacy-compatible. Unsupported versions are refused.
enabled Master switch for generation, comparison and sprites. Omitted/true keeps current behavior; false disables all generation entrypoints. Must be a boolean.
default Preferred { provider, model } pair. Provider is an authentication-specific route such as openai-api, codex-subscription, gemini-api, meta-api, meta-subscription, or a custom-provider id.
fallback Ordered provider/model pairs for safely classified default-generation failures. Omitted/empty disables fallback.
compare Provider/model pairs used only by explicit comparison requests. The default is not implicitly included.
defaultProvider Legacy authentication-specific default route; used when default is absent.
defaultModel Legacy model id or alias; ordinary generation needs this or a valid default.
outputDir Where to write generated images. Relative paths resolve against the session cwd. Default var/pi-image-gen/images.
requestTimeoutMs End-to-end deadline including inputs and downloads. 1000–900000; default 120000.
openRouterDiscovery Best-effort discovery of the selected OpenRouter model's supported parameters. Default true; failure falls back safely.
providers Per-built-in-provider override. Set apiKey, baseUrl, or headers to point at a proxy or non-standard env var. Firefly also accepts apiSecret or accessToken; the client id in apiKey remains required by the Firefly API.
customProviders User-defined providers — see below. Built-in route ids such as openai-api and meta-subscription are reserved and cannot be shadowed.
spriteGeneration Optional sprite-sheet processing settings. Disabled by default; see below. Invalid values fail closed to safe defaults.

Unconfigured generated output defaults to the repository-relative var/pi-image-gen/ tree (images, sprites, search) so future artifacts stay inside the project's var/ instead of .pi/. This applies only when neither settings nor a per-call outputDir supplies a destination: explicit values are honored exactly, including absolute paths outside the repository. Existing files under .pi/images are left in place and are not migrated automatically. Add var/ to a project's ignore rules if it does not already ignore it.

Disabling generation

Set pi-image-gen.enabled to false to disable every generation path in this package:

{ "pi-image-gen": { "enabled": false } }

Run /image-gen reload after editing settings (restart a standalone MCP server). In Pi, image_generate, image_compare and sprite_generate are removed from active tools; in the MCP server and native Durable extension those generation tools are omitted from the catalog. Direct library calls to generateImage(), compareImages() and runSpritePipeline() throw a body-free ImageGenError before route selection, credential lookup or provider calls, rather than returning a fake success. /image-gen list and /image-gen doctor report the disabled state without inspecting credentials. An invalid non-boolean value is rejected at the settings boundary.

This switch does not affect image_search, image_search_compare, the /image-search command, or the independent pi-image-search settings. Sprite generation still needs its own spriteGeneration.enabled: true and can never bypass the master switch.

In global and agent settings, apiKey, baseUrl, and headers values support $VAR and ${VAR} environment interpolation. Fallbacks require the braced form (for example, ${FOO:-default}); $FOO:-default is not supported. Project settings keep all of these placeholders literal.

Migrate existing settings to version 2

Load this extension version, then preview migration before applying it:

/image-gen migrate --dry-run
/image-gen migrate

The default scope is all: global, agent and the trusted current project. Identical paths are handled once. To select one scope:

/image-gen migrate --dry-run --scope project
/image-gen migrate --scope project

Other scopes are global and agent. Dry-run creates no backups, files or directories. Migration reports paths/statuses and field changes, never API keys or full settings contents.

Each existing JSON file is migrated individually from its raw contents, never from merged settings. Complete defaultProvider/defaultModel pairs become default; the old keys are removed and version: 2 is written. Existing nested defaults retain precedence. Credentials, custom providers, sprites, fallback/compare lists, unrelated namespaces and literal environment placeholders are preserved. Missing fallback/compare arrays are not filled with empty arrays, because that could disable inherited lists.

A model-only default is inferred only when the same-file routing is unambiguous and isolated from other layers' defaults/custom providers. Ambiguous Meta auto-auth, layered defaults, environment-dependent model names, multiple candidate providers and provider-only partial defaults are left unchanged with guidance to add an explicit same-file pair. A skipped file does not stop other independently safe files from migrating; mixed legacy/v2 loading remains supported. Untrusted projects, invalid JSON, symlinks, non-regular files and unsupported versions are not rewritten.

Before replacing a changed file, migration creates a unique adjacent private backup named settings.json.pi-image-gen-backup-<id>.bak containing its original bytes. It then writes a same-directory temporary file and atomically renames it, preserving the original permissions. An intervening source edit stops replacement. Backups may contain credentials: keep them private, do not commit them, and inspect them before manually restoring. Backups are retained; no automatic rollback is performed. Each file is atomic, not the whole multi-file command. Already-current files are no-ops, and successful writes reload the extension settings.

Image search

image_search finds existing images through Serper, Brave Search, SerpApi, Openverse, Tavily, Parallel Images API, or OpenAI Responses web_search image results. It is entirely separate from image generation: no generation models, credentials, default, fallback or compare routes are reused. It always downloads and validates candidates, returning usable local files plus source metadata. Optional resize saves exact-sized PNG copies. There is no URL-only mode or download flag. It never generates images.

Configure its separate pi-image-search namespace in settings.json:

{
  "pi-image-search": {
    "default": { "provider": "serper" },
    "fallback": [
      { "provider": "brave" },
      { "provider": "serpapi" }
    ],
    "compare": [
      { "provider": "serper" },
      { "provider": "brave" },
      { "provider": "serpapi" },
      { "provider": "openverse" }
    ],
    "requestTimeoutMs": 30000,
    "providers": {
      "serper": { "apiKey": "${SERPER_API_KEY}" },
      "brave": { "apiKey": "${BRAVE_SEARCH_API_KEY}" },
      "serpapi": { "apiKey": "${SERPAPI_API_KEY}" },
      "tavily": { "apiKey": "${TAVILY_API_KEY}" },
      "parallel": { "apiKey": "${PARALLEL_API_KEY}", "mode": "fast" },
      "openai-responses": { "apiKey": "${OPENAI_RESPONSES_API_KEY}", "model": "gpt-6.2-astra" }
    }
  }
}

The configuration follows the same default + fallback + compare pattern as generation. Search routes have only provider, not model, because these APIs search existing images rather than run generation models. Provider settings may still include parallel.mode (fast by default, or advanced) and openai-responses.model (gpt-6.2-astra by default, matching OpenAI's documented example). Omit fallback/compare to disable them. No default is silently chosen, and a fallback list cannot repeat its default or another fallback provider.

Search provider Credential environment variable Notes
serper SERPER_API_KEY Google Images via Serper
brave BRAVE_SEARCH_API_KEY Independent image index; strict safe search
serpapi SERPAPI_API_KEY Google Images via SerpApi; safe search enabled
openverse Optional OPENVERSE_ACCESS_TOKEN Anonymous access works at lower limits; optional apiKey is an existing Bearer access token, not a client secret
tavily TAVILY_API_KEY Tavily Search include_images; basic depth costs 1 API credit per request
parallel PARALLEL_API_KEY Dedicated Parallel Images API; fast $1/1,000 requests, advanced $5/1,000
openai-responses OPENAI_RESPONSES_API_KEY Responses web_search image results; separate from generation's OpenAI credential; web search including images is $10/1,000 calls plus content tokens

Official contracts: Tavily Search API, Tavily auth, Tavily credits, Parallel Images API, Parallel modes, Parallel pricing, OpenAI image search results, and OpenAI tool pricing. These adapters use only documented image URL fields; source page links remain metadata.

Search reads the same global, agent and trusted-project settings layers, but only its own namespace. Provider apiKey takes precedence over its environment variable. Environment placeholders expand only in global/agent settings, never in project settings. Keep keys out of committed project files. Unresolved placeholders are never sent as credentials. The extension never imports credentials from Bloom or another project.

/image-search list

This command shows configured routes and credential availability, never keys. Search settings are read fresh on every call; generation reload commands are not needed.

Search and compare

image_search({ query: "red panda in a tree", limit: 5 })
  • query: 1–200 characters after trimming, at most 50 words (the common supported provider limits).

  • limit: 1–20 candidates, default 5. Providers may return fewer. Every search downloads and validates candidates; only still JPEG, PNG and WebP are supported. Failed/unsupported candidates are excluded from images and listed in rejected with reasons. Download failure never starts a provider fallback or another search.

  • resize: optional { width, height, fit?: "contain" | "cover" }. Both dimensions must be integers from 1–8192, with at most 40 million pixels. contain (default) preserves proportions and pads transparently; cover explicitly crops. Output is PNG, with the original saved unchanged.

  • outputDir: optional download directory; default <cwd>/var/pi-image-gen/search. The library resolves relative paths against options.cwd (or the process cwd).

  • No provider/model overrides are accepted by the tool arguments; Parallel mode and OpenAI Responses model come only from provider settings.

  • The whole ordinary search, including fallback and downloads, shares one deadline: requestTimeoutMs defaults to 30000, allowed 1000–120000.

  • Configured fallback runs only for missing credentials or HTTP 401/403/404/429. Empty results are successful and do not trigger fallback. Timeout, transport errors, invalid responses and other HTTP failures stop the search; there is no blind retry.

  • Every fallback explicitly authorizes sending the query to another provider, which may have different coverage, terms and billing. Avoid mixing Openverse with general-web fallback when you require an open-license collection.

Use image_search_compare only when explicitly comparing providers:

image_search_compare({ query: "red panda in a tree", limit: 5 })

It searches exactly the compare list in order, reports successes/failures independently, never uses default/fallback, and never changes settings. Each entry has its own search deadline and may consume quota or incur charges. Cancellation prevents remaining entries from starting.

Results contain the actual provider, query, images and route attempts. Candidate metadata includes original imageUrl, available thumbnail/source links, dimensions, and Openverse creator/license/attribution. Missing fields remain unknown. Exact image URLs are deduplicated without stripping meaningful query parameters. Provider metadata is untrusted data, not instructions. Every returned image is successfully downloaded, format-checked and fully decoded, but this does not verify relevance, visual quality or reuse rights. Entries include path, mimeType and independently measured dimensions; the provider's width/height remain source hints. When resized, originalPath points to the untouched download. Source and license links are retained. No remote previews are attached.

Downloads use public-destination/redirect checks, no search credentials, bounded 20 MiB body reads, response-type checks, actual format detection, full decoding and a 40-million-pixel limit. SVG, GIF/animation, HEIC/HEIF, BMP, TIFF, ICO and other unsupported formats are rejected rather than converted. Each candidate has a 10-second download/processing deadline inside the whole-search deadline; native decoding is bounded by pixels/bytes but is not interruptible mid-operation. Results can be fewer than limit (including zero), and no replacement search is made. Failed candidates leave no completed files; cancellation removes this call's downloaded files. Product relevance, NSFW, blur, watermark and other quality checks are not performed.

image_search({
  query: "red panda in a tree", limit: 5,
  resize: { width: 1200, height: 800, fit: "contain" }
})

image_search_compare also always downloads and validates candidates per provider, with the same optional resize and outputDir parameters.

Always verify reuse rights at the original source. Openverse license metadata is useful evidence, not a guarantee. A web search hit does not imply permission to download, edit or redistribute it. For an authorized edit, a selected imageUrl can be passed to image_generate({ prompt: "...", image: [imageUrl] }); the existing generation reference loader separately checks URL safety and image bytes. Search never starts generation automatically.

Independent search library

The separate package entry does not import generation or Pi runtime modules:

import { searchImages, compareImageSearches } from '@abhishek944/pi-image-gen/search';

const settings = {
  default: { provider: 'serper' },
  fallback: [{ provider: 'brave' }],
  compare: [{ provider: 'serper' }, { provider: 'openverse' }],
};
const result = await searchImages({ query: 'red panda', limit: 5 }, { settings });
// Explicit comparison only:
const comparison = await compareImageSearches({ query: 'red panda', limit: 5 }, { settings });

Both functions accept an optional signal in the options. loadImageSearchSettings(cwd, projectTrusted) loads search settings explicitly for library hosts. The settings-only /durable entry additionally registers native image_search and image_search_compare tools from explicit search settings; this Node search entry itself does not claim a portable runtime.

DeepSeek Harness

Host pi-image-gen status
pi2dsh @amaster.ai/pi-image-gen@0.1.8 was exercised against a controlled OpenAI-compatible endpoint (scope and evidence).
dsh-pi-host Loads @amaster.ai/pi-image-gen when selected in its extensions list.

Follow the selected host's documentation for installation and current compatibility details.

Built-in setup walkthrough

1. OpenAI (gpt-image-2, GPT Image 2.5 and 2.6)

export OPENAI_API_KEY=sk-...
{ "pi-image-gen": { "defaultProvider": "openai-api", "defaultModel": "gpt-image-2.5-flare" } }

Choose gpt-image-2.5-flare for fast everyday generation or gpt-image-2.5-sunburst when editing precision matters most. Both expose low, medium, high, xhigh, max, and auto quality. Their -2026-09-08 snapshots are also built in. gpt-image-2 and its gpt-image-2-2026-04-21 snapshot remain available but retire on 2027-02-10; the replacement is GPT Image 2.6.

GPT Image 2.6 adds gpt-image-2.6-flare (fast iteration) and gpt-image-2.6-sunburst (detailed visual work). Both add complexity (low/medium/high, default high, no separate fee), native animated GIF output (outputFormat: "gif" with frameCount and frameDurationMs), native editable SVG output (outputFormat: "svg"; n must be 1), optional SVG author controls (svgModel/svgReasoningEffort when the account has SVG model selection enabled), and markup-guided edits (markup). They list low/medium/high/auto quality. GIF and SVG are generation-only Image API features: the edit endpoint does not support them, and they cannot be combined with reference images, masks, outputCompression, streaming, partial images, or prompt rewriting. Both features are account-gated (GIF preview access and SVG model selection); the provider returns the authoritative error when access is absent. The API reference and SDK bound frameCount to 2–16; the guide currently says 2–64, and this extension follows the API reference/SDK until the sources agree.

2. Google Gemini "Nano Banana"

export GEMINI_API_KEY=...
{ "pi-image-gen": { "defaultModel": "gemini-nano-banana-2.1" } }

Google recommends Nano Banana 2.1 for new projects. It exposes 1K/2K/4K and 14 aspect ratios. gemini-3.1-flash-image is deprecated in favor of 2.1, and gemini-2.5-flash-image retires on 2027-03-15. The 3.1 Flash tiny tier is the REST literal 512.

3. Alibaba DashScope (Qwen-Image)

export DASHSCOPE_API_KEY=...
{ "pi-image-gen": { "defaultModel": "qwen-image-2.0" } }

qwen-image-2.1-pro and qwen-image-2.1-turbo are also built in. They accept up to 10 references and may emit alpha automatically; negative prompts remain a 3.0-only control.

For the international DashScope endpoint, override the base URL:

{
  "pi-image-gen": {
    "defaultModel": "qwen-image-2.0",
    "providers": {
      "dashscope": { "baseUrl": "https://dashscope-intl.aliyuncs.com/api/v1" }
    }
  }
}

4. Volcengine Ark (ByteDance Seedream)

export ARK_API_KEY=...
{ "pi-image-gen": { "defaultModel": "seedream" } }

Supported size values are model-dependent, and the tool schema tells the agent the exact form for the active model: a tier token (1K/1.5K/2K/3K/4K — the list differs per model) or an explicit "<w>x<h>" pixel string, never mixed. Seedream 5.5, 5.0 Pro and 5.0 Flash accept 1K/1.5K/2K down to 921,600 px; 5.0 Lite and 4.5 enforce a 2K floor; 4.0 accepts 1K. Full sizing matrix in the official docs. Seedream has no n parameter, so n is hidden. Legacy non-Pro models expose seriesMaxImages; 5.x models use layer decomposition instead. The extension sends watermark: false by default to avoid Seedream's upstream "AI 生成" badge, while an explicit watermark: true opts in.

Seedream 5.5 (doubao-seedream-5-5-261028) and 5.0 Flash (doubao-seedream-5-0-flash-260915) are built in. 5.5/5.0 Pro/5.0 Flash expose background for RGBA output; transparent forces PNG. On 5.0 Pro/Flash, transparent output also requires one transparent input image; 5.5 supports transparent text-to-image. 5.x also exposes layerDecomposition with exactly one input image. layerMaxImages is a 5.5-only request control, provider-verified as 2–100 including the base. 5.0 Pro/Flash do not expose that control, but their documented layer batches may contain up to 17 outputs (one base plus 16 layers); 5.5 alone adds layerTextRecognition. Complete layer batches above the ordinary 10-image ceiling are admitted up to those provider-verified caps. Layer mode cannot be combined with background, and layer metadata is not currently surfaced separately; layers are saved in provider order.

The default base URL is https://ark.cn-beijing.volces.com/api/v3. To use a different region (e.g. ap-southeast), override it:

{
  "pi-image-gen": {
    "defaultModel": "seedream",
    "providers": {
      "ark": { "baseUrl": "https://ark.ap-southeast.bytepluses.com/api/v3" }
    }
  }
}

5. Meta Muse Image

Meta works with either subscription login or an API key.

Subscription login: install pi-meta-oauth, then authenticate in Pi. Check that package's current Pi peer-version range first; OAuth support is optional, and META_API_KEY remains available on Pi versions outside it.

pi install npm:pi-meta-oauth
/login meta

API key: create a key in the Meta Model API dashboard, then configure:

export META_API_KEY=...

Legacy MODEL_API_KEY is also accepted. Select the funding route explicitly:

/image-gen use meta-subscription muse-image
/image-gen use meta-api muse-image
{ "pi-image-gen": { "defaultProvider": "meta-subscription", "defaultModel": "muse-image" } }

With a legacy model-only configuration, an active Meta login still takes precedence and an API key remains the fallback. With an explicit route, meta-subscription uses only Pi OAuth and meta-api uses only the configured API key.

OAuth credentials are resolved and refreshed through Pi at request time. They are used only for the built-in Meta provider at api.meta.ai, never for custom providers or overridden endpoints. The built-in route now uses Muse Image's documented one-shot POST /v1/images/generations and POST /v1/images/edits endpoints; custom api: meta providers keep the conversational Responses wire shape. Generate from text normally; for editing or composition, pass one or more images through the tool's image array. Official size examples include 1024x1024, 1536x1024, and 1024x1536; these are guidance rather than an exhaustive enum, and Meta validates the requested value. Muse Image produces one output per request, so n and quality are hidden.

6. OpenRouter (one key, many models)

export OPENROUTER_API_KEY=...
{ "pi-image-gen": { "defaultModel": "openrouter/bytedance-seed/seedream-4.5" } }

The string after openrouter/ is the OpenRouter model slug; pass any image model OpenRouter supports (google/gemini-3.1-flash-image, openai/gpt-image-2, bytedance-seed/seedream-4.5, …).

OpenRouter's image API is not OpenAI-compatible despite the family name — it lives at POST /api/v1/images (no /generations suffix) and uses JSON input_references for image-to-image. The extension targets the right endpoint automatically; no wire-shape config needed.

Since OpenRouter's 2026-11-19 response change, inline b64_json is optional and signed data[].url responses are valid. The extension explicitly sends response_format: "b64_json" by default and can request responseFormat: "url". Both data[].url and top-level expires_at are accepted; a validated expiry appears as metadata.expiresAt (Unix seconds). Signed links are bearer URLs and are downloaded once into the saved output.

7. Additional direct providers

Built-in routes bfl-api, adobe-firefly-api, stability-api, comfy-api, ideogram-api, minimax-api, kling-api, krea-api, together-api, cloudflare-api, and recraft-api use their providers' native contracts. FLUX, Firefly, and Ideogram async jobs poll the URL or generation id returned by the submit response. Stability uses documented multipart /v2beta endpoints; Comfy reuses that multipart builder at https://stability.comfy.org with the same three generation paths and Bearer auth. Ideogram uses multipart generate/precise-edit and Api-Key; a mask routes to precise edit, which forbids size. MiniMax uses synchronous JSON generations/edits. Kling submits a task to POST /image-generation/kling-4.0 and polls GET /tasks?task_ids=. Krea submits POST /generate/image/krea/krea-3 and polls GET /jobs/{job_id}. Together uses its documented /v1/images/generations JSON contract. Cloudflare uses the account-scoped Workers AI REST path. Recraft uses its dedicated JSON REST API for generation, native SVG models, image-to-image, inpaint, outpaint, background operations, vectorization, and processing tools.

export BFL_API_KEY=...
export FIREFLY_SERVICES_CLIENT_ID=...
export FIREFLY_SERVICES_CLIENT_SECRET=... # or FIREFLY_SERVICES_ACCESS_TOKEN
export STABILITY_API_KEY=...
export COMFY_API_KEY=...
export IDEOGRAM_API_KEY=...
export MINIMAX_API_KEY=...
export KLING_API_KEY=...
export KREA_API_KEY=...
export TOGETHER_API_KEY=...
export RECRAFT_API_TOKEN=...
{ "pi-image-gen": { "default": { "provider": "recraft-api", "model": "recraftv4_1" } } }

Gemini 2.1 / 3.1 Flash models additionally expose thinkingLevel, includeThoughts, searchGrounding, and imageSearchGrounding through generateContent. Thought parts are skipped when saving; only the final image is stored. Alibaba wan2.7-image-pro and wan2.7-image expose verified tier/pixel sizes, seed, watermark, thinkingMode, optional asyncMode, and sequentialMaxImages; z-image-turbo is text-to-image only. Recraft controls such as operation, styleId, styleReferenceUrls, textLayout, colorControls, and strength appear only for models whose official contract supports them.

FLUX.3 Image accepts width/height or a resolution tier (768sq, 1k, 1.5k, 2k, 4k, plus match_input on flux-3-image); FLUX.3 Klein additionally exposes seed and png/jpeg output. Both take up to ten reference URLs through images, and edits with references are capped at 4MP by the provider. FLUX.2 keeps its input_image contract. Ideogram 4.6 exposes size (auto, auto_2k, auto_4k, source, or exact WIDTHxHEIGHT), background, seed, promptEnhance, mask, and asyncMode; a mask switches to precise edit, which keeps the first image's size and therefore rejects size. MiniMax exposes aspectRatio plus imageSize (1K/2K/4K) instead of a pixel-size field, accepts up to 16 reference images on edits, and supports png/jpeg/webp.

Firefly always requires the client id (x-api-key); supply either the client secret for IMS token exchange or an already acquired access token. A custom provider using api: "adobe-firefly" can carry the same credentials through apiKey, apiSecret, and accessToken. For FLUX.2 and FLUX.3 editing, pass public image URLs: the direct APIs document URL references and have no local upload endpoint in the verified contract. Firefly uploads local reference bytes through its documented storage endpoint. Ideogram and MiniMax accept local reference bytes through multipart or data URIs.

Kling Image 4.0 (kling-api, kling-image-4.0) uses the documented global host https://api-singapore.klingai.com and Bearer auth. Requests carry contents (a prompt plus up to ten combined refer_image entries) and optional settings: n (1–9 independent images), result_type: "series" with series_amount (2–10, or auto) for a coordinated set, resolution (2k/4k/8k) and aspect_ratio (auto plus eight ratios). seriesMaxImages and n are mutually exclusive here — Kling ignores n in series mode, so the route rejects the combination instead of dropping it. Every request is asynchronous: the submit response returns a task id and the adapter polls GET /tasks?task_ids= for submitted/processing/succeeded/failed, reading outputs[].url for the images. Local references are sent as bare base64 in contents[].url (the documented "URL or Base64" field); public URLs are forwarded unchanged. The separate /long-image-generation/kling-4.0 endpoint (required skill, 1k/2k only) is not exposed. Kling retains result URLs for 30 days, so saved files are the durable copy.

Krea 3 (krea-api, krea-3) uses https://api.krea.ai with Bearer auth and the documented job lifecycle: POST /generate/image/krea/krea-3 returns job_id, then the adapter polls GET /jobs/{job_id} until completed and saves result.urls. Controls are aspectRatio (ten documented ratios, no auto), imageSize (1K/2K/4K), thinkingMode (fast/high/ultra), seed, negativePrompt, and up to eight references. Local reference bytes are sent as data URIs, which Krea documents alongside asset and external URLs. ultra always returns 2K and rejects negative prompts, so the route rejects imageSize: "4K"/"1K" and negativePrompt locally when thinkingMode is ultra; Krea also gates ultra on a Max-or-above plan. Krea offers the same model on OpenRouter as krea/k3-edit, but OpenRouter's catalog entry for it advertises only 1K/2K output, aspect ratio and seed — thinking modes, 4K, and regional edits exist only on the direct API. Bounding-box regions and regional_edit are not exposed by this package.

Together AI (together-api) routes together/<model-id> through the documented POST https://api.together.ai/v1/images/generations contract. It is OpenAI-shaped but not OpenAI-compatible, so it is a distinct adapter: size is sent as the documented height/width pair, responseFormat: "b64_json" becomes response_format: "base64", outputFormat is png/jpeg, and seed and negativePrompt are forwarded. Image inputs use the documented JSON image_url (one reference) or reference_images (several) fields, which take public URLs only — Together publishes no upload endpoint. Together does not publish a per-model size range or a reference-count ceiling, so those stay advisory and the provider's error is authoritative. It resells other vendors' open-weight models (black-forest-labs/FLUX.2-dev, Seedream, Qwen-Image, …); use the owner's own route or OpenRouter when you need model-specific controls.

Firefly always requires the client id (x-api-key); supply either the client secret for IMS token exchange or an already acquired access token. A custom provider using api: "adobe-firefly" can carry the same credentials through apiKey, apiSecret, and accessToken. For FLUX.2 and FLUX.3 editing, pass public image URLs: the direct APIs document URL references and have no local upload endpoint in the verified contract. Firefly uploads local reference bytes through its documented storage endpoint. Ideogram and MiniMax accept local reference bytes through multipart or data URIs.

Azure OpenAI image deployments

Use azure-openai-api for Azure-hosted GPT Image models. It is separate from public OpenAI API billing, the Codex subscription route, and Azure MAI. No credential falls back to those other providers.

export AZURE_OPENAI_API_KEY="your-azure-resource-key"

In ~/.pi/agent/settings.json (or agent settings):

{
  "pi-image-gen": {
    "defaultProvider": "azure-openai-api",
    "defaultModel": "your-image-deployment",
    "providers": {
      "azure-openai": {
        "baseUrl": "https://your-resource.openai.azure.com/openai/v1"
      }
    }
  }
}

Set defaultModel to the Azure deployment name, not necessarily the catalog model name. Select it in Pi with /image-gen use azure-openai-api your-image-deployment.

  • Credentials: providers.azure-openai.apiKey first, then local AZURE_OPENAI_API_KEY. You can use ${AZURE_OPENAI_API_KEY} in global/agent settings; project settings do not interpolate environment placeholders. The built-in route sends the key in api-key and rejects redirects; it does not read Pi /login credentials or refresh Entra tokens.
  • Endpoint: providers.azure-openai.baseUrl first, then local AZURE_OPENAI_ENDPOINT. An HTTPS resource root, /openai/v1 base, or full v1 /images/generations or /images/edits URL is accepted. No userinfo, query parameters, fragments, project path, or legacy deployment-scoped URL is accepted. Only configure an endpoint you trust: credentials are sent there.
  • Requests use the existing OpenAI image API wire format: JSON generations and multipart edits, both with ?api-version=preview. The integration does not call the legacy /openai/deployments/... API and requires no Azure SDK.
  • Catalog profiles: gpt-image-1-mini, gpt-image-1.5, gpt-image-2, gpt-image-2-2026-04-21, gpt-image-2.5-flare, gpt-image-2.5-sunburst. These only work when deployed in your resource. gpt-image-1 shut down on 2026-10-23 and is no longer advertised; 1-mini and 1.5 retire on 2026-12-01, and 2/2 snapshot on 2027-02-10. Arbitrary deployment names are passed through unchanged and receive common GPT Image control advice rather than a guessed model version. Catalog-named deployments receive their known quality/size profile. DALL-E 3 is retired and is not advertised.
  • Supports generation, reference-image editing, masks, quality, PNG/JPEG output, background and JPEG compression controls. Microsoft's image guide excludes WebP output for Azure; direct OpenAI's formats are unchanged. Model-specific options and numeric limits remain Azure's authority. GPT Image 2.5 profiles expose xhigh and max in addition to the common quality values. This extension keeps its existing 20MB-per-input and 128MB-combined safety ceilings.

See Microsoft's image generation guide for regional/model access and deployment requirements.

Microsoft MAI on Azure Foundry

Use the mai-api route. Set defaultModel to your Azure deployment name, not necessarily the model's catalog name. MAI has no shared default endpoint: configure the resource endpoint explicitly.

export AZURE_MAI_API_KEY="your-azure-resource-key"

In ~/.pi/agent/settings.json (or your agent settings):

{
  "pi-image-gen": {
    "defaultProvider": "mai-api",
    "defaultModel": "your-mai-deployment",
    "providers": {
      "mai": {
        "baseUrl": "https://your-resource.services.ai.azure.com/mai/v1"
      }
    }
  }
}

Optionally set providers.mai.apiKey to a credential or ${AZURE_MAI_API_KEY} in global/agent settings. A nonblank settings key takes precedence over AZURE_MAI_API_KEY; otherwise the environment variable is read directly. Environment placeholders are not expanded in project settings. Credentials are sent to the configured endpoint, so use a trusted resource or gateway.

A resource-root URL also works: the adapter adds /mai/v1. Do not include /images/generations, /images/edits, query parameters, or a project endpoint path. Requests use the api-key header and reject redirects. The built-in route does not use Pi /login or refresh Entra credentials.

After loading the updated extension, select the deployment with:

/image-gen use mai-api your-mai-deployment

Microsoft's current documented catalog:

Catalog model Deployment version Lifecycle
MAI-Image-2.5 2026-06-02 Retires 2026-11-24
MAI-Image-2.5-Flash 2026-06-02 Retires 2026-11-24
MAI-Image-2.5-Pro 2026-06-19 Retires 2026-11-24
MAI-Image-2.6 2026-07-31 GA; retires 2027-05-01
MAI-Image-2.6-Flash 2026-07-31 GA; retires 2027-05-01
MAI-Image-2.7 2026-11-02 Preview
MAI-Image-2.7-Flash 2026-11-02 Preview

The version is selected when deploying in Azure; it is not a generation-request setting. Arbitrary deployment names (including older deployments) are passed through unchanged. Catalog-named deployments receive the known model's size advice; arbitrary deployment names receive family-level guidance without guessing their version.

  • Text-to-image: POST /mai/v1/images/generations; size: "1024x1024" becomes integer width and height. Each dimension must be at least 768. MAI 2.5 permits at most 1,048,576 total pixels; MAI 2.6 permits at most 2,359,296. Microsoft's inspected 2.7 documentation does not publish a pixel ceiling, so no local maximum is invented; Azure validates the deployed model's limits.
  • Editing: POST /mai/v1/images/edits with multipart form data and repeated image fields. Current documented models accept up to five PNG/JPEG references. Omit size for edits; the documented edits API has no width/height control. Older deployments may not support edits.
  • Output is a base64-encoded PNG, saved through the existing image pipeline. No n greater than 1, quality, mask, output-format/compression, or seed controls are exposed. PNG output does not guarantee transparency; the sprite pipeline still requires real alpha. MAI 2.7 deployments expose background: "transparent" for documented transparent generation; earlier deployments reject this control.
  • MAI 2.6-specific auto_aspect_ratio and web_grounding controls are not exposed by this integration.

See Microsoft's MAI image API reference for availability, quotas, and current preview limitations.

Custom providers

Use customProviders for anything not built in: a self-hosted Stable Diffusion, an internal corp gateway, a third-party image API. The shape mirrors pi.dev's custom-provider docs.

Each custom provider declares:

Field Required Notes
api yes One of openai, gemini, dashscope, openrouter, cloudflare, ark, meta, mai, bfl, adobe-firefly, stability, ideogram, minimax, kling, krea, recraft. Picks the image-API wire shape.
baseUrl no API endpoint URL; defaults to the selected api adapter's built-in endpoint when omitted, except mai, which requires a resource-specific URL. Environment interpolation follows the settings-file rules above.
apiKey usually Credential string. $VAR syntax supported. Required for bearer and header authentication.
auth no { "type": "bearer" }, { "type": "header", "header": "x-api-key" }, or explicit { "type": "none" }. Omission preserves the adapter's legacy default (Gemini uses x-goog-api-key, MAI uses api-key, Ideogram uses Api-Key; the others use bearer).
name no Display name shown in /image-gen list.
headers no Extra headers merged into every request.
models no Optional model id/alias list. Omit to make this a catch-all — the provider will accept any unknown model id (passed through as the remote id). Provide a list only when you want aliases or want to route specific ids elsewhere. Each entry is a string or { id, alias?, name?, capabilities? }.

Requests using a named credential header reject redirects so that a gateway cannot forward that credential to another origin.

A custom model whose id names a built-in model inherits that model's capability contract (size form, n ceiling, reference-image rules) so the tool schema stays accurate when you route a known model through your own gateway. Declare capabilities on the entry to override individual fields; anything undeclared falls back to the built-in entry, then to a conservative generic contract. Catch-all routes and unknown ids get no contract — the schema stays fully generic, as before.

{
  "pi-image-gen": {
    "defaultModel": "qwen-image-3.0",
    "customProviders": {
      "corp-gateway": {
        "api": "dashscope",
        "baseUrl": "https://gateway.corp.example/api/v1",
        "apiKey": "$GW_KEY",
        "auth": { "type": "bearer" },
        "models": [
          "qwen-image-3.0",
          { "id": "my-finetune", "capabilities": { "nMax": 4, "maxReferenceImages": 2 } }
        ]
      }
    }
  }
}

Note: pi.dev custom providers also have an api field, but its values (openai-completions, anthropic-messages, …) are LLM streaming formats that don't apply to image generation. The values here (openai, gemini, dashscope, openrouter, cloudflare, ark, meta, mai, bfl, adobe-firefly, stability, ideogram, minimax, kling, krea, recraft) are image-API wire shapes — same field name, different namespace.

Example: self-hosted Stable Diffusion (OpenAI-compatible)

export SD_KEY=local-secret
{
  "pi-image-gen": {
    "defaultModel": "sd3",
    "customProviders": {
      "my-sd": {
        "api": "openai",
        "baseUrl": "http://localhost:8000/v1",
        "apiKey": "$SD_KEY",
        "models": [{ "id": "sd-3-large", "alias": "sd3" }]
      }
    }
  }
}

The agent calls image_generate({prompt: ...}); the extension sees defaultModel: "sd3", finds it under my-sd, and POSTs to http://localhost:8000/v1/images/generations with Bearer $SD_KEY.

Example: Volcengine Doubao image API (OpenAI-compatible)

{
  "pi-image-gen": {
    "defaultModel": "doubao-seed-image",
    "customProviders": {
      "doubao": {
        "api": "openai",
        "baseUrl": "https://ark.cn-beijing.volces.com/api/v3",
        "apiKey": "${ARK_API_KEY}",
        "models": [{ "id": "doubao-seedream-4-0-250828", "alias": "doubao-seed-image" }]
      }
    }
  }
}

Example: Cloudflare Workers AI REST image generation

The cloudflare wire shape uses Cloudflare's documented REST model-in-path endpoint. It posts { prompt } to POST /accounts/{account_id}/ai/run/{model}, sends the Cloudflare API token as a bearer credential, requires cf-aig-gateway-id for Workers AI, and reads the documented base64 image from the REST API's { result: { image } } envelope (the raw model output { image } is also accepted). baseUrl must include the account path and end in /ai/run. Only text prompts and an optional seed are sent. size, quality, aspectRatio and imageSize are rejected before dispatch instead of being silently dropped or recorded as effective; image edits and output-format knobs are not claimed. The separate local resize option still runs after generation.

The built-in cloudflare-api route uses the same adapter and catalog entry for @cf/black-forest-labs/flux-1-schnell. Because Workers AI is account-scoped, it has no usable shared default URL: set providers.cloudflare.baseUrl and the gateway header, then use /image-gen use cloudflare-api @cf/black-forest-labs/flux-1-schnell. FLUX.2 klein/dev are not catalogued because they require multipart bodies this JSON adapter cannot send, and the Leonardo models document width/height/guidance controls this adapter does not forward.

{
  "pi-image-gen": {
    "providers": {
      "cloudflare": {
        "baseUrl": "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/ai/run",
        "apiKey": "${CLOUDFLARE_API_TOKEN}",
        "headers": { "cf-aig-gateway-id": "${CLOUDFLARE_AI_GATEWAY_ID}" }
      }
    }
  }
}
{
  "pi-image-gen": {
    "default": { "provider": "cf-images", "model": "cf-flux" },
    "customProviders": {
      "cf-images": {
        "api": "cloudflare",
        "baseUrl": "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/ai/run",
        "apiKey": "${CLOUDFLARE_API_TOKEN}",
        "headers": { "cf-aig-gateway-id": "${CLOUDFLARE_AI_GATEWAY_ID}" },
        "models": [
          {
            "id": "@cf/black-forest-labs/flux-1-schnell",
            "alias": "cf-flux",
            "capabilities": {
              "nMax": 1,
              "supportsSeed": true,
              "maxReferenceImages": 0
            }
          }
        ]
      }
    }
  }
}

This is distinct from the trusted host-only Cloudflare binding/catalog route. It does not call gateway.ai.cloudflare.com provider-native endpoints, and those endpoints' chat/response documentation does not establish image support.

Example: LiteLLM image gateway (OpenAI wire shape)

LiteLLM documents POST /v1/images/generations and POST /v1/images/edits with OpenAI-shaped requests and bearer virtual keys. Configure the model in LiteLLM's model_list first, then use the ordinary OpenAI adapter:

{
  "pi-image-gen": {
    "default": { "provider": "litellm-images", "model": "my-image-model" },
    "customProviders": {
      "litellm-images": {
        "api": "openai",
        "baseUrl": "https://litellm.example/v1",
        "apiKey": "${LITELLM_VIRTUAL_KEY}",
        "models": [{ "id": "my-image-model" }]
      }
    }
  }
}

This is generic OpenAI-compatible behavior, not a package-blessed LiteLLM profile. Model capabilities and provider-reported cost remain unknown unless declared in settings or returned by the gateway.

Example: a Gemini-shape proxy

If your provider speaks the Google Generative Language wire format:

{
  "pi-image-gen": {
    "defaultModel": "internal-banana",
    "customProviders": {
      "internal": {
        "api": "gemini",
        "baseUrl": "https://gemini-proxy.corp.example/v1beta",
        "apiKey": "$INTERNAL_GEMINI_KEY",
        "models": [{ "id": "gemini-2.5-flash-image", "alias": "internal-banana" }]
      }
    }
  }
}

Direct addressing without an alias

If a custom provider has no models list, you can still address it with <providerName>/<remoteId>:

{
  "pi-image-gen": {
    "defaultModel": "my-sd/sd-3-large",
    "customProviders": {
      "my-sd": { "api": "openai", "baseUrl": "http://localhost:8000/v1", "apiKey": "$SD_KEY" }
    }
  }
}

Optional sprite generation

image_generate remains the general image tool. Enable the separate sprite_generate tool only when you need one coherent action sheet plus deterministic local processing:

{
  "pi-image-gen": {
    "defaultProvider": "openai-api",
    "defaultModel": "gpt-image-2",
    "spriteGeneration": {
      "enabled": true,
      "defaultRows": 2,
      "defaultColumns": 3,
      "defaultFormat": "apng",
      "frameDurationMs": 120,
      "strictValidation": true,
      "outputDir": "var/pi-image-gen/sprites",
      "maxFrames": 16
    }
  }
}

Run /image-gen reload after editing settings. The command reports whether sprite generation is enabled. Toggling it changes only sprite_generate; all other active tools are preserved.

A call makes exactly one provider request through the same generateImage() service used by image_generate. The model creates one full sheet, then local code splits cells in row-major order, segments alpha foreground, applies one shared scale, aligns frames, checks geometry and silhouette motion, and writes transparent PNG assets. No automatic paid retry occurs.

sprite_generate({
  prompt: "the same red-jacket courier running in place, crisp pixel art",
  image: ["references/courier.png"],
  assetType: "player",
  action: "run",
  view: "side",
  rows: 2,
  columns: 3,
  frameCount: 6,
  align: "feet",
  scaleStrategy: "fit",
  componentMode: "largest",
  format: "apng",
  frameDurationMs: 120,
  filename: "courier-run"
})

Six frames default to a 2×3 grid. frameCount