Skip to content

Output Image Formats

By default /v2/job returns generated images as JPEG, but the Accept request header lets you ask for PNG, WebP, or a tuned JPEG instead — and pass extra MIME parameters to control quality and compression. The pixels stay identical (same model, same seed) so you can pick a format and quality level that fits how you store, ship, or display the result.

This guide walks through the three formats end-to-end with the same prompt and seed, so you can compare file size against visual quality.

Terminal window
# Create a project directory.
mkdir prodia-output-formats
cd prodia-output-formats

Install Node (if not already installed):

Terminal window
brew install node
# Close the current terminal and open a new one so that node is available.

Create project skeleton:

Terminal window
# Requires node --version >= 18
# Initialize the project with npm.
npm init -y
# Install the prodia-js library.
npm install prodia --save
Terminal window
# Export your token so it can be used by the main code.
export PRODIA_TOKEN=your-token-here

Your token is exported to an environment variable. If you close or switch your shell you’ll need to run export PRODIA_TOKEN=your-token-here again.

Create a main file for your project:

main.js
const { createProdia } = require("prodia/v2");
const prodia = createProdia({
token: process.env.PRODIA_TOKEN // get it from environment
});

You’re now ready to make some API calls!

JPEG is the default. It’s lossy and uses chroma subsampling — best for photographic generations where small file size matters more than pixel-exact fidelity.

main.js
const { createProdia } = require("prodia/v2");
const fs = require("node:fs/promises");
const prodia = createProdia({
token: process.env.PRODIA_TOKEN,
});
(async () => {
const job = await prodia.job({
type: "inference.flux-fast.schnell.txt2img.v2",
config: {
prompt: "a single fresh strawberry on a polished white marble countertop, soft daylight from the side, photorealistic, shallow depth of field",
seed: 42,
width: 1024,
height: 1024,
},
}, { accept: "image/jpeg" });
const image = await job.arrayBuffer();
await fs.writeFile("strawberry.jpg", new Uint8Array(image));
})();
Terminal window
node main.js

The default JPEG comes back at quality 75 with 4:2:0 chroma subsampling — about 53 KB for our 1024x1024 strawberry:

1024x1024 strawberry rendered as a default JPEG, ~54 KB

Append MIME parameters to the Accept value to override the defaults. The ones the API accepts are:

ParameterTypeRangeDefaultDescription
qualityint0–9575Compression quality (higher = better quality, larger file)
optimizebool0/1falseOptimize Huffman tables for smaller file size
progressivebool0/1falseCreate progressive JPEG (loads in multiple passes)
subsamplingstring444/422/420420Chroma subsampling (444 = best quality, 420 = smallest)

For a higher-fidelity JPEG, ask for quality=95 and subsampling=444 (no chroma loss):

main.js
const job = await prodia.job({
type: "inference.flux-fast.schnell.txt2img.v2",
config: {
prompt: "a single fresh strawberry on a polished white marble countertop, soft daylight from the side, photorealistic, shallow depth of field",
seed: 42,
width: 1024,
height: 1024,
},
}, { accept: "image/jpeg;quality=95;subsampling=444" });

The same image now weighs about 142 KB (≈2.6x larger) with cleaner reds in the strawberry surface and crisper marble veining:

1024x1024 strawberry at JPEG quality 95 with 4:4:4 subsampling, ~142 KB

For thumbnail-size assets where bandwidth matters more than fidelity, drop quality to 50:

{ accept: "image/jpeg;quality=50" }

That brings the same 1024x1024 image down to ~39 KB — visibly softer in the marble veining, but still acceptable for previews:

1024x1024 strawberry at JPEG quality 50, ~39 KB

Ask for image/png when you need an exact copy of the model output — useful for downstream pipelines that compare hashes, run pixel-perfect post-processing, or feed the output into another inference step where re-encoding artifacts would compound. PNG is also the right choice for outputs with transparency (e.g. backgrounds removed via inference.remove-background.v1).

main.js
const job = await prodia.job({
type: "inference.flux-fast.schnell.txt2img.v2",
config: {
prompt: "a single fresh strawberry on a polished white marble countertop, soft daylight from the side, photorealistic, shallow depth of field",
seed: 42,
width: 1024,
height: 1024,
},
}, { accept: "image/png" });
const image = await job.arrayBuffer();
await fs.writeFile("strawberry.png", new Uint8Array(image));

PNG is lossless, so it’s larger — around 861 KB for the same 1024x1024 strawberry:

1024x1024 strawberry as lossless PNG, ~861 KB

PNG accepts two encoding parameters:

ParameterTypeRangeDefaultDescription
compress-levelint0–96Compression level (0 = none, 9 = maximum)
optimizebool0/1falseOptimize encoding for smaller file size

Both only affect file size — pixels are byte-identical for any setting:

Terminal window
-H 'Accept: image/png;compress-level=9;optimize=1'

WebP gives the best size-quality tradeoff of the three. Lossy WebP at the default quality of 80 is typically smaller than even a low-quality JPEG, while lossless WebP is smaller than PNG — useful when you need pixel-exact output but want to save on storage.

main.js
const job = await prodia.job({
type: "inference.flux-fast.schnell.txt2img.v2",
config: {
prompt: "a single fresh strawberry on a polished white marble countertop, soft daylight from the side, photorealistic, shallow depth of field",
seed: 42,
width: 1024,
height: 1024,
},
}, { accept: "image/webp" });
const image = await job.arrayBuffer();
await fs.writeFile("strawberry.webp", new Uint8Array(image));

The default lossy WebP for our 1024x1024 strawberry is around 29 KB — about half the default JPEG, with no obvious quality loss:

1024x1024 strawberry as lossy WebP at quality 80, ~29 KB

WebP accepts the most parameters of any format:

ParameterTypeRangeDefaultDescription
qualityint0–10080Compression quality (higher = better quality, larger file)
losslessbool0/1falseUse lossless compression (ignores quality setting)
alpha-qualityint0–100100Quality of alpha channel compression
methodint0–64Compression method (0 = fastest, 6 = best compression)

For a lossless WebP — same exact pixels as PNG, smaller file:

Terminal window
-H 'Accept: image/webp;lossless=1;method=6'

That brings the file down to ~610 KB versus PNG’s ~861 KB on the same image — a ~30% saving with byte-identical decoded pixels.

GoalFormat
Smallest file for typical photographic outputimage/webp
Default — wide compatibility, small fileimage/jpeg
Pixel-exact output for hashing or downstream inferenceimage/png or image/webp;lossless=1
Outputs with transparency (e.g. background-removed PNGs)image/png
Highest-fidelity JPEG (no chroma subsampling)image/jpeg;quality=95;subsampling=444
Smaller PNG without quality lossimage/png;compress-level=9;optimize=1

All sizes are for the same 1024x1024 strawberry generation (seed 42) used throughout this guide:

Accept valueSizeNotes
image/jpeg (default)53 KBquality 75, 4:2:0 subsampling
image/jpeg;quality=5039 KBvisibly softer, fine for thumbnails
image/jpeg;quality=95;subsampling=444142 KBsharpest JPEG
image/png861 KBlossless, no transparency in this output
image/webp (default)29 KBlossy, quality 80 — smallest of all
image/webp;lossless=1;method=6610 KBlossless, ~30% smaller than PNG

Some job types return more than one output (e.g. multipart segmentation masks, video plus poster frame). For those, request a multipart response and override the default output content type with a secondary value in the Accept header:

Terminal window
-H 'Accept: multipart/form-data; image/png'

The first output part will be encoded as PNG; any additional parts use their native default. See the Inference API reference for the full content-negotiation rules.