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
| Field | Description |
|---|---|
model | Image model identifier |
prompt | Image instruction |
count | Number of requested images |
size | Output dimensions or auto |
quality | Provider-supported quality level |
style | Provider-supported visual style |
format | png, jpeg, webp, or future provider format |
responseFormat | url or base64 |
background | Transparent, 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.