1 model := "openai/gpt-image-1" 2 size := "1024x1024" 3 quality := "high" 4 outputFormat := "webp" 5 n := 1 6 7 resp, err := client.Images.Generate(ctx, meshapi.ImageGenerationParams{ 8 Model: &model, 9 Prompt: "A watercolor of a fox in a snowy forest", 10 N: &n, 11 Size: &size, 12 Quality: &quality, 13 OutputFormat: &outputFormat, 14 }) 15 if err != nil { 16 log.Fatal(err) 17 } 18 19 if len(resp.Data) > 0 { 20 fmt.Println(*resp.Data[0].URL) 21 }
1 chunkCh, errCh := client.Images.Stream(ctx, meshapi.ImageGenerationParams{ 2 Model: &model, 3 Prompt: "A watercolor of a fox in a snowy forest", 4 N: &n, 5 Size: &size, 6 Quality: &quality, 7 OutputFormat: &outputFormat, 8 }) 9 10 for chunk := range chunkCh { 11 if chunk.Status != nil && *chunk.Status == "processing" { 12 fmt.Println("Generating...") 13 } else if len(chunk.Data) > 0 && chunk.Data[0].URL != nil { 14 fmt.Println("Done:", *chunk.Data[0].URL) 15 } 16 } 17 if err := <-errCh; err != nil { 18 log.Fatal(err) 19 }
| 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 |