dalle

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2022 License: MPL-2.0 Imports: 9 Imported by: 2

README

go-dalle

DALL-E API Wrapper for Go.

Installation

go get github.com/astralservices/go-dalle

Usage

package main

import (
    "fmt"
    "github.com/astralservices/go-dalle"
)

func main() {
    apiKey := os.Getenv("DALLE_API_KEY")
    client := dalle.NewClient(apiKey)

    data, err := client.Generate("A horse in an elevator", nil, nil, nil, nil)

    if err != nil {
        fmt.Println(err)
    }

    fmt.Println(data[0].URL)
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Documentation

Index

Constants

View Source
const (
	Small  int = 256
	Medium int = 512
	Large  int = 1024
)

Sizes

View Source
const (
	URLFormat        = "url"
	Base64JSONFormat = "b64_json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Generate(prompt string, size *int, n *int, user *string, responseType *string) ([]Datum, error)
	Edit(prompt string, image *os.File, mask *os.File, size *int, n *int, user *string, responseType *string) ([]Datum, error)
	Variation(image *os.File, size *int, n *int, user *string, responseType *string) ([]Datum, error)
}

func NewClient

func NewClient(apiKey string) Client

type Datum

type Datum struct {
	URL string `json:"url"`
}

type GenerateRequest

type GenerateRequest struct {
	Prompt         string  `json:"prompt"`
	N              *int    `json:"n,omitempty"`
	Size           *string `json:"size,omitempty"`
	ResponseFormat *string `json:"response_format,omitempty"`
	User           *string `json:"user,omitempty"`
}

type Response

type Response struct {
	Created int64   `json:"created"`
	Data    []Datum `json:"data"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL