flux

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Overview

Example
client := NewClient("http://xe-flux.flycast")

if _, err := client.HealthCheck(); err != nil {
	fmt.Println("Error health checking:", err)
	panic(err)
}

// Example of using the Predict method
predictionReq := PredictionRequest{
	Input: Input{
		Prompt:            "A beautiful sunrise over the mountains",
		NumOutputs:        1,
		GuidanceScale:     7.5,
		MaxSequenceLength: 256,
		NumInferenceSteps: 50,
		PromptStrength:    0.8,
		OutputFormat:      "png",
		OutputQuality:     90,
	},
	ID:                  "example-prediction-id",
	CreatedAt:           time.Now().Format(time.RFC3339),
	OutputFilePrefix:    "output",
	Webhook:             "http://example.com/webhook",
	WebhookEventsFilter: []string{"start", "completed"},
}

predictionResp, err := client.Predict(predictionReq)
if err != nil {
	fmt.Println("Error predicting:", err)
} else {
	fmt.Println("PredictionResponse:", predictionResp)
}

// Example of using the PredictIdempotent method
predictionResp, err = client.PredictIdempotent("example-prediction-id", predictionReq)
if err != nil {
	fmt.Println("Error predicting idempotent:", err)
} else {
	fmt.Println("PredictIdempotentResponse:", predictionResp)
}

// Example of using the CancelPrediction method
resp, err := client.CancelPrediction("example-prediction-id")
if err != nil {
	fmt.Println("Error cancelling prediction:", err)
} else {
	body, _ := ioutil.ReadAll(resp.Body)
	fmt.Println("CancelPrediction response:", string(body))
	resp.Body.Close()
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
}

func NewClient

func NewClient(baseURL string) *Client

func (*Client) CancelPrediction

func (c *Client) CancelPrediction(predictionID string) (*http.Response, error)

func (*Client) HealthCheck

func (c *Client) HealthCheck() (*HealthCheckResponse, error)

HealthCheck checks the health of the service

func (*Client) Predict

func (c *Client) Predict(predictionReq PredictionRequest) (*PredictionResponse, error)

func (*Client) PredictIdempotent

func (c *Client) PredictIdempotent(predictionID string, predictionReq PredictionRequest) (*PredictionResponse, error)

type HTTPValidationError

type HTTPValidationError struct {
	Detail []ValidationError `json:"detail"`
}

type HealthCheckResponse

type HealthCheckResponse struct {
	Status string `json:"status"`
}

HealthCheckResponse represents the response structure for the health check endpoint.

type Input

type Input struct {
	Prompt            string  `json:"prompt"`
	Image             string  `json:"image,omitempty"`
	AspectRatio       string  `json:"aspect_ratio,omitempty"`
	NumOutputs        int     `json:"num_outputs"`
	GuidanceScale     float64 `json:"guidance_scale"`
	MaxSequenceLength int     `json:"max_sequence_length"`
	NumInferenceSteps int     `json:"num_inference_steps"`
	PromptStrength    float64 `json:"prompt_strength"`
	Seed              *int    `json:"seed,omitempty"`
	OutputFormat      string  `json:"output_format"`
	OutputQuality     int     `json:"output_quality"`
}

type Output

type Output []string

type PredictionRequest

type PredictionRequest struct {
	Input               Input    `json:"input"`
	ID                  string   `json:"id,omitempty"`
	CreatedAt           string   `json:"created_at,omitempty"`
	OutputFilePrefix    string   `json:"output_file_prefix,omitempty"`
	Webhook             string   `json:"webhook,omitempty"`
	WebhookEventsFilter []string `json:"webhook_events_filter,omitempty"`
}

type PredictionResponse

type PredictionResponse struct {
	Input       Input                  `json:"input"`
	Output      Output                 `json:"output"`
	ID          string                 `json:"id"`
	Version     string                 `json:"version"`
	CreatedAt   string                 `json:"created_at"`
	StartedAt   string                 `json:"started_at"`
	CompletedAt string                 `json:"completed_at"`
	Logs        string                 `json:"logs"`
	Error       string                 `json:"error"`
	Status      string                 `json:"status"`
	Metrics     map[string]interface{} `json:"metrics"`
}

type ValidationError

type ValidationError struct {
	Loc  []interface{} `json:"loc"`
	Msg  string        `json:"msg"`
	Type string        `json:"type"`
}

Jump to

Keyboard shortcuts

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