> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.meshapi.ai/llms.txt.
> For full documentation content, see https://developers.meshapi.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.meshapi.ai/_mcp/server.

# Image Generation

> Generate images with the Node.js SDK.

# Image Generation

```ts
const result = await client.images.generate({
  model: "openai/gpt-image-1",
  prompt: "A watercolor of a fox in a snowy forest",
  n: 1,
  size: "1024x1024",
  quality: "high",
  output_format: "webp",
});

console.log(result.data[0].url);
```

## Streaming

```ts
const stream = client.images.stream({
  model: "openai/gpt-image-1",
  prompt: "A watercolor of a fox in a snowy forest",
  n: 1,
  size: "1024x1024",
  quality: "high",
  output_format: "webp",
});

for await (const chunk of stream) {
  if (chunk.status === "processing") {
    console.log("Generating...");
  } else if (chunk.data?.length) {
    console.log("Done:", chunk.data[0].url);
  }
}
```

## Parameters

| Field             | Type                        | Notes                                                         |
| ----------------- | --------------------------- | ------------------------------------------------------------- |
| `prompt`          | `string`                    | Required                                                      |
| `model`           | `string`                    | e.g. `"openai/gpt-image-1"`                                   |
| `n`               | `number`                    | Number of images (1–10)                                       |
| `size`            | `string`                    | `"auto"`, `"1024x1024"`, `"WIDTHxHEIGHT"`                     |
| `quality`         | `string`                    | `"auto"`, `"low"`, `"medium"`, `"high"`, `"hd"`, `"standard"` |
| `response_format` | `"url" \| "b64_json"`       |                                                               |
| `output_format`   | `"png" \| "jpeg" \| "webp"` | OpenAI only                                                   |
| `stream`          | `boolean`                   | Enable SSE keep-alive streaming                               |