Image

rw.image()

Generate images from a text prompt. Returns timestamps and an array of image objects with URLs.

Signature

TypeScript
rw.image(model: string, prompt: string, options?: ImageOptions): Promise<ImageResponse>

Parameters

ParameterTypeDescription
model
required
stringImage model slug, e.g. "flux-schnell", "dall-e-3", "stable-diffusion-3.5-large"
prompt
required
stringText description of the image to generate.
options.nnumberNumber of images to generate.Default: 1
options.sizestring"256x256", "512x512", "1024x1024", "1024x1792", "1792x1024"Default: "1024x1024"
options.qualitystringImage quality setting, e.g. "standard" or "hd".
options.stylestringStyle preset, e.g. "vivid" or "natural".
options.negative_promptstringThings to exclude from the generated image.

Response

TypeScript
interface ImageResponse {
  created: number;
  data: {
    url: string;
    revised_prompt?: string;
  }[];
}

Examples

Basic image generation

TypeScript
const res = await rw.image("flux-schnell", "A beautiful sunset over Tokyo");
console.log(res.data[0].url);

Multiple images with options

TypeScript
const res = await rw.image("flux-schnell", "A cyberpunk cityscape", {
  size: "1024x1024",
  n: 2,
  negative_prompt: "blurry, low quality, distorted",
});

for (const img of res.data) {
  console.log(img.url);
}

Using DALL-E 3

TypeScript
const res = await rw.image("dall-e-3", "A watercolor painting of a library", {
  quality: "hd",
  style: "natural",
});

console.log(res.data[0].url);
console.log(res.data[0].revised_prompt); // DALL-E's enhanced prompt

Supported image models

Flux (schnell, 1.1-pro, dev), DALL-E 2/3, Stable Diffusion 3.5, Ideogram v2, Recraft v3, and more. Browse at /models.