> 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 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 Python SDK.

# Image Generation

```python
from meshapi import ImageGenerationParams

result = client.images.generate(
    ImageGenerationParams(
        model="openai/gpt-image-1",
        prompt="A watercolor of a fox in a snowy forest",
        n=1,
        size="1024x1024",
        quality="high",
        output_format="webp",
    )
)

print(result.data[0].url)
```

## Streaming

```python
for chunk in client.images.stream(
    ImageGenerationParams(
        model="openai/gpt-image-1",
        prompt="A watercolor of a fox in a snowy forest",
        n=1,
        size="1024x1024",
        quality="high",
        output_format="webp",
    )
):
    if chunk.status == "processing":
        print("Generating...")
    elif chunk.data:
        print("Done:", chunk.data[0].url)
```

### Async

```python
from meshapi import AsyncMeshAPI, ImageGenerationParams

async_client = AsyncMeshAPI()

async for chunk in async_client.images.stream(
    ImageGenerationParams(
        model="openai/gpt-image-1",
        prompt="A watercolor of a fox in a snowy forest",
        n=1,
        size="1024x1024",
        quality="high",
        output_format="webp",
    )
):
    if chunk.status == "processing":
        print("Generating...")
    elif chunk.data:
        print("Done:", chunk.data[0].url)
```

## Parameters

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