Documentation
¶
Index ¶
Constants ¶
const (
// DefaultDomain is the default API endpoint used if no custom domain is provided.
DefaultDomain = "https://api.openai.com"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// The API key to use for authentication.
APIKey string
// The Domain to use for the API.
Domain string
// The HTTP client to use for requests.
Client http.Client
}
Client is the main struct for the Dalle API client.
func NewClient ¶
func NewClient(apiKey string, domain string, opts ...ClientOption) (*Client, error)
NewClient initializes and returns a new instance of the Dalle API client. It requires a non-empty API key and optionally accepts a custom domain. Additional configuration can be applied using functional options.
func (*Client) GenerateImageV1 ¶
GenerateImageV1 sends a request to generate an image from a provided prompt. It takes a prompt string, the number of images (n), and the size as parameters. The function returns the response as a byte slice or an error if any.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption defines a function type for configuring the Client. It allows for modular and flexible client configuration.
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient returns a ClientOption that sets a custom HTTP client for making API requests.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout returns a ClientOption that configures the timeout duration for API requests.
type ImageGenerationRequest ¶
type ImageGenerationRequest struct {
Prompt string `json:"prompt"`
N int `json:"n"`
Size string `json:"size"`
}
ImageGenerationRequest is the request body for the image generation endpoint.