For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
DocsAPI ReferenceSDKs
DocsAPI ReferenceSDKs
      • Overview
      • Chat Completions
      • Prompt Templates
      • Files & Batches
      • Embeddings
      • Image Generation
      • Responses (Reasoning)
      • Compare (Multi-model)
      • Models
      • Error Handling
LogoLogo
On this page
  • Image Generation
  • Streaming
  • Parameters
Node.js SDK

Image Generation

||View as Markdown|
Was this page helpful?
Edit this page
Previous

Embeddings

Next

Responses API (Reasoning)

Built with

Image Generation

1const result = await client.images.generate({
2 model: "openai/gpt-image-1",
3 prompt: "A watercolor of a fox in a snowy forest",
4 n: 1,
5 size: "1024x1024",
6 quality: "high",
7 output_format: "webp",
8});
9
10console.log(result.data[0].url);

Streaming

1const stream = client.images.stream({
2 model: "openai/gpt-image-1",
3 prompt: "A watercolor of a fox in a snowy forest",
4 n: 1,
5 size: "1024x1024",
6 quality: "high",
7 output_format: "webp",
8});
9
10for await (const chunk of stream) {
11 if (chunk.status === "processing") {
12 console.log("Generating...");
13 } else if (chunk.data?.length) {
14 console.log("Done:", chunk.data[0].url);
15 }
16}

Parameters

FieldTypeNotes
promptstringRequired
modelstringe.g. "openai/gpt-image-1"
nnumberNumber of images (1–10)
sizestring"auto", "1024x1024", "WIDTHxHEIGHT"
qualitystring"auto", "low", "medium", "high", "hd", "standard"
response_format"url" | "b64_json"
output_format"png" | "jpeg" | "webp"OpenAI only
streambooleanEnable SSE keep-alive streaming