Image Generation
Image Generation
1 from meshapi import ImageGenerationParams 2 3 result = client.images.generate( 4 ImageGenerationParams( 5 model="openai/gpt-image-1", 6 prompt="A watercolor of a fox in a snowy forest", 7 n=1, 8 size="1024x1024", 9 quality="high", 10 output_format="webp", 11 ) 12 ) 13 14 print(result.data[0].url)
Streaming
1 for chunk in client.images.stream( 2 ImageGenerationParams( 3 model="openai/gpt-image-1", 4 prompt="A watercolor of a fox in a snowy forest", 5 n=1, 6 size="1024x1024", 7 quality="high", 8 output_format="webp", 9 ) 10 ): 11 if chunk.status == "processing": 12 print("Generating...") 13 elif chunk.data: 14 print("Done:", chunk.data[0].url)
Async
1 from meshapi import AsyncMeshAPI, ImageGenerationParams 2 3 async_client = AsyncMeshAPI() 4 5 async for chunk in async_client.images.stream( 6 ImageGenerationParams( 7 model="openai/gpt-image-1", 8 prompt="A watercolor of a fox in a snowy forest", 9 n=1, 10 size="1024x1024", 11 quality="high", 12 output_format="webp", 13 ) 14 ): 15 if chunk.status == "processing": 16 print("Generating...") 17 elif chunk.data: 18 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 |