Skip to content

dillonstreator/dalle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dalle

go client for DALL*E

Usage

This tool requires access to DALL*E. If you don't currently have access, sign up for the DALL*E wait list.

Find the Bearer Token

Note: Do not include "Bearer " in the api key

Using the api key

// create the client with the bearer token api key
dalleClient, err := dalle.NewHTTPClient("your-api-key-here")
// handle err

// generate a task to create an image with a prompt
task, err := dalleClient.Generate(ctx, "neon sports car driving into sunset, synthwave, cyberpunk")
// handle err

// poll the task.ID until status is succeeded
var t *dalle.Task
for {
    time.Sleep(time.Second * 3)

    t, err = dalleClient.GetTask(ctx, task.ID)
    // handle err

    if t.Status == dalle.StatusSucceeded {
        fmt.Println("task succeeded")
        break
    } else if t.Status == dalle.StatusRejected {
        log.Fatal("rejected: ", t.ID)
    }

    fmt.Println("task still pending")
}

// download the first generated image
reader, err := dalleClient.Download(ctx, t.Generations.Data[0].ID)
// handle err and close readCloser

Examples

About

openai dalle http client

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages