You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add support for image generation using gpt-image-1 (#971)
* feat: add gpt-image-1 support
* feat: add example to generate image using gpt-image-1 model
* style: missing period in comments
* feat: add missing fields to example
* docs: add GPT Image 1 to README
* revert: keep `examples/images/main.go` unchanged
* docs: remove unnecessary newline from example in README file
Copy file name to clipboardExpand all lines: README.md
+61-1Lines changed: 61 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ This library provides unofficial Go clients for [OpenAI API](https://platform.op
7
7
8
8
* ChatGPT 4o, o1
9
9
* GPT-3, GPT-4
10
-
* DALL·E 2, DALL·E 3
10
+
* DALL·E 2, DALL·E 3, GPT Image 1
11
11
* Whisper
12
12
13
13
## Installation
@@ -357,6 +357,66 @@ func main() {
357
357
```
358
358
</details>
359
359
360
+
<details>
361
+
<summary>GPT Image 1 image generation</summary>
362
+
363
+
```go
364
+
package main
365
+
366
+
import (
367
+
"context"
368
+
"encoding/base64"
369
+
"fmt"
370
+
"os"
371
+
372
+
openai "github.com/sashabaranov/go-openai"
373
+
)
374
+
375
+
funcmain() {
376
+
c:= openai.NewClient("your token")
377
+
ctx:= context.Background()
378
+
379
+
req:= openai.ImageRequest{
380
+
Prompt: "Parrot on a skateboard performing a trick. Large bold text \"SKATE MASTER\" banner at the bottom of the image. Cartoon style, natural light, high detail, 1:1 aspect ratio.",
381
+
Background: openai.CreateImageBackgroundOpaque,
382
+
Model: openai.CreateImageModelGptImage1,
383
+
Size: openai.CreateImageSize1024x1024,
384
+
N: 1,
385
+
Quality: openai.CreateImageQualityLow,
386
+
OutputCompression: 100,
387
+
OutputFormat: openai.CreateImageOutputFormatJPEG,
388
+
// Moderation: openai.CreateImageModerationLow,
389
+
// User: "",
390
+
}
391
+
392
+
resp, err:= c.CreateImage(ctx, req)
393
+
if err != nil {
394
+
fmt.Printf("Image creation Image generation with GPT Image 1error: %v\n", err)
0 commit comments