Generate
Creates an image given a prompt
images.generate(ImageGenerateParams**kwargs) -> ImageGenerateResponse
/images/generations
Creates a high-quality image from a text prompt using GPT-IMAGE-1, the latest image generation model with automatic prompt optimization and enhanced visual capabilities.
Parameters
Returns
Creates an image given a prompt
from gradient import Gradient
client = Gradient(
access_token="My Access Token",
)
response = client.images.generate(
prompt="A cute baby sea otter floating on its back in calm blue water",
)
print(response.created)
{
"created": 1677649456,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX...",
"revised_prompt": "A cute baby sea otter floating on its back in calm blue water, captured with professional photography lighting and composition"
}
],
"background": "opaque",
"output_format": "png",
"quality": "high",
"size": "1024x1024",
"usage": {
"input_tokens": 12,
"total_tokens": 4172,
"input_tokens_details": {
"text_tokens": 12
},
"output_tokens": 4160
}
}
Returns Examples
{
"created": 1677649456,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAAA1BMVEX...",
"revised_prompt": "A cute baby sea otter floating on its back in calm blue water, captured with professional photography lighting and composition"
}
],
"background": "opaque",
"output_format": "png",
"quality": "high",
"size": "1024x1024",
"usage": {
"input_tokens": 12,
"total_tokens": 4172,
"input_tokens_details": {
"text_tokens": 12
},
"output_tokens": 4160
}
}