Creates an image given a prompt
client.Images.Generate(ctx, body) (*ImageGenerateResponse, error)
/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
package main
import (
"context"
"fmt"
"github.com/stainless-sdks/-go"
"github.com/stainless-sdks/-go/option"
)
func main() {
client := gradient.NewClient(
option.WithModelAccessKey("My Model Access Key"),
)
response, err := client.Images.Generate(context.TODO(), gradient.ImageGenerateParams{
Prompt: gradient.F("A cute baby sea otter floating on its back in calm blue water"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", 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
}
}