Nirmos
TypeScript SDKGateway

Image generation

Generate images through Nirmos with normalized output.

Use nirmos.gateway.images.generate:

const result = await nirmos.gateway.images.generate({
  model: "openai/gpt-image-1",
  prompt: "A restrained isometric illustration of an AI gateway",
  size: "1024x1024",
  quality: "high",
  format: "png",
});

for (const image of result.images) {
  console.log(image.url ?? image.base64);
}

Common options

FieldDescription
modelImage model identifier
promptImage instruction
countNumber of requested images
sizeOutput dimensions or auto
qualityProvider-supported quality level
styleProvider-supported visual style
formatpng, jpeg, webp, or future provider format
responseFormaturl or base64
backgroundTransparent, opaque, or automatic background behavior

Model-specific options may not be supported by every provider. Nirmos validates the request against the selected route.

Base64 output

const result = await nirmos.gateway.images.generate({
  model: "openai/gpt-image-1",
  prompt: "Minimal black and white mountain icon",
  responseFormat: "base64",
  background: "transparent",
});

const encoded = result.images[0]?.base64;

Normalized image data

Each generated image can include:

type GeneratedImage = {
  url?: string;
  base64?: string;
  revisedPrompt?: string;
  mediaType?: string;
  width?: number;
  height?: number;
};

Download URL-based images promptly if your provider returns expiring URLs. Treat generated content as untrusted input when displaying it in user-facing applications.

On this page