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

# Image Generation

```go
model := "openai/gpt-image-1"
size := "1024x1024"
quality := "high"
outputFormat := "webp"
n := 1

resp, err := client.Images.Generate(ctx, meshapi.ImageGenerationParams{
    Model:        &model,
    Prompt:       "A watercolor of a fox in a snowy forest",
    N:            &n,
    Size:         &size,
    Quality:      &quality,
    OutputFormat: &outputFormat,
})
if err != nil {
    log.Fatal(err)
}

if len(resp.Data) > 0 {
    fmt.Println(*resp.Data[0].URL)
}
```

## Streaming

```go
chunkCh, errCh := client.Images.Stream(ctx, meshapi.ImageGenerationParams{
    Model:        &model,
    Prompt:       "A watercolor of a fox in a snowy forest",
    N:            &n,
    Size:         &size,
    Quality:      &quality,
    OutputFormat: &outputFormat,
})

for chunk := range chunkCh {
    if chunk.Status != nil && *chunk.Status == "processing" {
        fmt.Println("Generating...")
    } else if len(chunk.Data) > 0 && chunk.Data[0].URL != nil {
        fmt.Println("Done:", *chunk.Data[0].URL)
    }
}
if err := <-errCh; err != nil {
    log.Fatal(err)
}
```

## Parameters

| Field            | Type      | Notes                                                         |
| ---------------- | --------- | ------------------------------------------------------------- |
| `Prompt`         | `string`  | Required                                                      |
| `Model`          | `*string` | e.g. `"openai/gpt-image-1"`                                   |
| `N`              | `*int`    | Number of images (1–10)                                       |
| `Size`           | `*string` | `"auto"`, `"1024x1024"`, `"WIDTHxHEIGHT"`                     |
| `Quality`        | `*string` | `"auto"`, `"low"`, `"medium"`, `"high"`, `"hd"`, `"standard"` |
| `ResponseFormat` | `*string` | `"url"` or `"b64_json"`                                       |
| `OutputFormat`   | `*string` | `"png"`, `"jpeg"`, or `"webp"`. OpenAI only                   |
| `Stream`         | `*bool`   | Enable SSE keep-alive streaming                               |