dalle2

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SMALL  = "256x256"
	MEDIUM = "512x512"
	LARGE  = "1024x1024"

	URL    = "url"
	BASE64 = "b64_json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiKeyTransport

type ApiKeyTransport struct {
	ApiKey    string
	Transport http.RoundTripper
}

func (*ApiKeyTransport) RoundTrip

func (t *ApiKeyTransport) RoundTrip(req *http.Request) (*http.Response, error)

type Client

type Client interface {
	Create(context.Context, string, ...Option) (*Response, error)
	Edit(context.Context, []byte, []byte, string, ...Option) (*Response, error)
	Variation(context.Context, []byte, ...Option) (*Response, error)
}

func MakeNewClientV1

func MakeNewClientV1(apiKey string) (Client, error)

type ClientV1

type ClientV1 struct {
	Url       *url.URL
	UserAgent string
	// contains filtered or unexported fields
}

func (*ClientV1) Create

func (c *ClientV1) Create(ctx context.Context, prompt string, opts ...Option) (*Response, error)

func (*ClientV1) Edit

func (c *ClientV1) Edit(ctx context.Context, image, mask []byte, prompt string, opts ...Option) (*Response, error)

func (*ClientV1) Variation

func (c *ClientV1) Variation(ctx context.Context, image []byte, opts ...Option) (*Response, error)

type ErrorDetails

type ErrorDetails struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Param   string `json:"param,omitempty"`
	Type    string `json:"type,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
	ErrorDetails *ErrorDetails `json:"error,omitempty"`
}

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

type Option

type Option func(*apiOption)

func WithFormat

func WithFormat(format string) Option

func WithNumImages

func WithNumImages(n uint8) Option

func WithSize

func WithSize(size string) Option

func WithUser

func WithUser(user string) Option

type OutputImage

type OutputImage struct {
	Base64 string `json:"b64_json,omitempty"`
	Url    string `json:"url,omitempty"`
}

type Response

type Response struct {
	Created int64          `json:"created,omitempty"`
	Data    []*OutputImage `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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