← Catalog

pi-deepinfra-imagegen

Native pi image tool powered by DeepInfra: generate_image with per-model schemas, reference images, real PNG alpha, and review sidecars

Extension

Install

Install with PiG

pig install npm:pi-deepinfra-imagegen

Install with Pi

pi install npm:pi-deepinfra-imagegen
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./extensions/deepinfra-imagegen.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.1.3 (README.md). PiG does not review it.

pi-deepinfra-imagegen

npm version npm downloads license pi package

A pi extension package that gives pi a native image tool backed by DeepInfra, so design work that needs raster output (comps, decision comps, plates, textured assets) can run comp-first on a DeepInfra-only setup.

pi install npm:pi-deepinfra-imagegen

Then restart pi or run /reload: the generate_image tool and the /deepinfra-image command are available, and every generation lands on disk next to a prompt sidecar.

Why an extension

pi's built-in image path is codemode → models.generateImages(), and it only speaks openrouter-images: OpenRouter's chat completions endpoint with modalities: ["image"]. DeepInfra serves images over /v1/openai/images/generations and /v1/inference/<model>, and models.json has no way to declare an image-type model. So DeepInfra image models cannot be reached through models.generateImages(); this extension registers a real tool instead. impeccable generate-image (the skill's fallback CLI) is hardcoded to api.openai.com with OPENAI_API_KEY and cannot be repointed.

Install

pi install npm:pi-deepinfra-imagegen     # into ~/.pi/agent/settings.json
pi install -l npm:pi-deepinfra-imagegen  # or project-scoped .pi/settings.json
pi -e npm:pi-deepinfra-imagegen          # or try it for one run

Requires pi (any recent release) and Node 20 or newer. Pin an exact version with npm:pi-deepinfra-imagegen@0.1.3; without a pin, pi update --extensions moves you to the newest release.

Without npm, install straight from the tagged repo — pi clones it and pins the ref:

pi install git:github.com/ronald-08/pi-deepinfra-imagegen@v0.1.3
pi -e git:github.com/ronald-08/pi-deepinfra-imagegen@v0.1.3

Then restart pi or run /reload. The tool generate_image is active by default. Updates: pi update --extensions. Removal: pi remove npm:pi-deepinfra-imagegen.

Credentials, resolved in order:

  1. pi's credential store for the deepinfra provider — /login deepinfra, or the pi-deepinfra provider package
  2. DEEPINFRA_API_KEY
  3. ~/.pi/agent/auth.json → deepinfra.key

Tool

generate_image({
  prompt: "…",            // sent verbatim
  out: ".impeccable/mocks/comp-a.png",
  model: "google/nano-banana-pro",
  refs: [".impeccable/mocks/ref/home.png"],
  size: "1440x900",       // or "16:9", or "2K"
  transparent: false,     // true = generate, then Bria RMBG for real alpha
  seed: 7,
  count: 1,
  preview: true           // inline image in the result when the model takes images
})

It writes the image plus a prompt sidecar at <out>.json ({ prompt, model, size, refs, background, mimeType, costUsd, createdAt }), preserving an existing "approved": true. Impeccable's build-phase advance reads exactly that.

Details worth knowing:

  • Parameters are per-model. The tool fetches the model's in_schema from the public DeepInfra API and sends only fields that model declares: width/height, size, or aspect_ratio; image, image_urls, or input_image[_N]. The catalog and per-model schemas are cached in $PI_CODING_AGENT_DIR/cache/deepinfra-imagegen.json (24 h; /deepinfra-image refresh).
  • Reference encoding differs. Black Forest Labs models take raw base64 and reject data URLs; everything else takes data URLs. The tool picks the known encoding and retries the other once if the input is rejected.
  • Format honesty. Some models ignore a PNG request (sdxl-turbo, Seedream, Qwen can return JPEG). The file is written with its true extension and the deviation is reported, instead of writing JPEG bytes into a .png path.
  • Presigned URLs. BFL returns a presigned delivery URL; it is fetched without the API key (an extra Authorization header breaks the signature).
  • Cost is DeepInfra's reported inference_status.cost, plus the Bria call when transparent: true.

Command

/deepinfra-image opens a picker over the catalog — the same keyboard-driven list as /scoped-models — with the active model marked * and per-image price on each row. Selecting a row validates that model's schema and sets it for the session; cancelling leaves the session model untouched.

  • /deepinfra-image list — plain-text list (scriptable, no dialog; also the fallback when ctx.hasUI is false, i.e. -p/JSON mode)
  • /deepinfra-image <model> — set the session model directly, no dialog
  • /deepinfra-image refresh — re-fetch the catalog, then open the picker
  • Argument completion suggests model ids from the cached catalog
  • Legend: * = this session, + = saved default

Persist a default for all new sessions

Picking in the bare picker only changes the session. To make a model the default every new pi session starts with:

  • /deepinfra-image default — picker that saves its choice globally
  • /deepinfra-image default <model> — save a specific model globally
  • /deepinfra-image default clear — drop the saved default

After a session pick the command also asks “Use for all new sessions?”, so the picker can set the global default without a second command.

The choice is stored in $PI_CODING_AGENT_DIR/deepinfra-imagegen.json ({ "defaultModel": "…" }, normally ~/.pi/agent/deepinfra-imagegen.json), next to the disposable catalog cache at cache/deepinfra-imagegen.json. It is a plain file, so it survives /reload, restarts, and package updates.

Resolution order, most specific first:

  1. model argument of a generate_image call
  2. session pick (picker, <model>, default …)
  3. saved default — deepinfra-imagegen.json
  4. DEEPINFRA_IMAGE_MODEL environment variable (deployment override)
  5. built-in google/nano-banana-pro

So DEEPINFRA_IMAGE_MODEL still works for CI or a launcher that cannot use the command, but a model saved through the command wins over it.

Default model: google/nano-banana-pro. Good alternatives:

ModelUseCost
google/nano-banana-procomps, type, edits, 1 reference~$0.13/image
black-forest-labs/FLUX-2-proup to 4 references, exact pixel size, PNG$0.015–0.075
black-forest-labs/FLUX-2-klein-9bcheaper FLUX 2$0.014
ByteDance/Seedream-4fast 2K/4K, 1 reference$0.04
stabilityai/sdxl-turbodrafts only, weak prompt adherence$0.0002
Bria/remove_backgroundused internally for transparent: true$0.018

Models that return PNG natively: nano-banana-pro, FLUX (output_format: png is forced), Bria. For Impeccable plates (PNG required), prefer those, or transparent: true, which always lands on a PNG.

Using it with Impeccable comp-first

  1. Ensure the extension is loaded (generate_image in the tool list) and the session model accepts image input, so the model can actually look at comps it generates (DeepInfra vision-tagged models, e.g. deepseek-ai/DeepSeek-V4.1-Flash).
  2. $impeccable init then the normal new-work flow: when it asks comp-first vs code-first, choose comp-first.
  3. The tool's promptGuidelines tell the model that generate_image is this harness's image tool, so Impeccable treats image generation as available even though impeccable context prints no IMAGE_GEN_AVAILABLE line (that line keys off OPENAI_API_KEY, which this setup does not need).
  4. Comps: generate_image to .impeccable/mocks/<name>.png with refs pointing at a representative existing page when the project has an established identity.
  5. Plates: the asset producer passes the comp crop as refs[0], and transparent: true for cutouts.
  6. After approving a comp, set "approved": true in <comp>.json.

Development

No build step; pi loads the TypeScript file directly.

pi -e ./            # load this checkout for one run
npm test            # command + default-model tests (Node >= 22.18, no dependencies)
npm pack --dry-run  # inspect what would be published

The test file drives the real extension through a stubbed pi host and a stubbed fetch, so it needs no API key and no network.

License

MIT