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
| Parameter | Type | Description |
|---|---|---|
modelrequired | string | Image model slug, e.g. "flux-schnell", "dall-e-3", "stable-diffusion-3.5-large" |
promptrequired | string | Text description of the image to generate. |
options.n | number | Number of images to generate.Default: 1 |
options.size | string | "256x256", "512x512", "1024x1024", "1024x1792", "1792x1024"Default: "1024x1024" |
options.quality | string | Image quality setting, e.g. "standard" or "hd". |
options.style | string | Style preset, e.g. "vivid" or "natural". |
options.negative_prompt | string | Things 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 promptSupported 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.