Install
Install with PiG
pig install npm:pi-deepinfra-imagegenInstall with Pi
pi install npm:pi-deepinfra-imagegenPackages 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
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:
- pi's credential store for the
deepinfraprovider —/login deepinfra, or thepi-deepinfraprovider package DEEPINFRA_API_KEY~/.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_schemafrom the public DeepInfra API and sends only fields that model declares:width/height,size, oraspect_ratio;image,image_urls, orinput_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,Qwencan return JPEG). The file is written with its true extension and the deviation is reported, instead of writing JPEG bytes into a.pngpath. - Presigned URLs. BFL returns a presigned delivery URL; it is fetched without the
API key (an extra
Authorizationheader breaks the signature). - Cost is DeepInfra's reported
inference_status.cost, plus the Bria call whentransparent: 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 whenctx.hasUIis 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:
modelargument of agenerate_imagecall- session pick (picker,
<model>,default …) - saved default —
deepinfra-imagegen.json DEEPINFRA_IMAGE_MODELenvironment variable (deployment override)- 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:
| Model | Use | Cost |
|---|---|---|
google/nano-banana-pro | comps, type, edits, 1 reference | ~$0.13/image |
black-forest-labs/FLUX-2-pro | up to 4 references, exact pixel size, PNG | $0.015–0.075 |
black-forest-labs/FLUX-2-klein-9b | cheaper FLUX 2 | $0.014 |
ByteDance/Seedream-4 | fast 2K/4K, 1 reference | $0.04 |
stabilityai/sdxl-turbo | drafts only, weak prompt adherence | $0.0002 |
Bria/remove_background | used 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
- Ensure the extension is loaded (
generate_imagein the tool list) and the session model accepts image input, so the model can actually look at comps it generates (DeepInfravision-tagged models, e.g.deepseek-ai/DeepSeek-V4.1-Flash). $impeccable initthen the normal new-work flow: when it asks comp-first vs code-first, choose comp-first.- The tool's
promptGuidelinestell the model thatgenerate_imageis this harness's image tool, so Impeccable treats image generation as available even thoughimpeccable contextprints noIMAGE_GEN_AVAILABLEline (that line keys offOPENAI_API_KEY, which this setup does not need). - Comps:
generate_imageto.impeccable/mocks/<name>.pngwithrefspointing at a representative existing page when the project has an established identity. - Plates: the asset producer passes the comp crop as
refs[0], andtransparent: truefor cutouts. - After approving a comp, set
"approved": truein<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