Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // WithTimeout sets the maximum time to wait for completion. WithTimeout = api.WithTimeout // WithPollInterval sets the interval between status checks. WithPollInterval = api.WithPollInterval // WithSyncMode enables or disables synchronous mode. WithSyncMode = api.WithSyncMode // WithMaxRetries sets the maximum number of task-level retries. WithMaxRetries = api.WithMaxRetries // WithUploadTimeout sets the timeout for file upload. WithUploadTimeout = api.WithUploadTimeout )
Option constructors
View Source
var API = &APIConfig{ APIKey: os.Getenv("WAVESPEED_API_KEY"), BaseURL: "https://api.wavespeed.ai", ConnectionTimeout: 10.0, Timeout: 36000.0, MaxRetries: 0, MaxConnectionRetries: 5, RetryInterval: 1.0, }
API is the global API configuration instance.
Functions ¶
func Run ¶ added in v0.2.0
Run executes a model and waits for the output.
Args:
- model: Model identifier (e.g., "wavespeed-ai/z-image/turbo").
- input: Input parameters for the model.
- opts: Optional parameters (WithTimeout, WithSyncMode, etc.)
Returns:
- map[string]any containing "outputs" array with model outputs.
Example:
import "github.com/WaveSpeedAI/wavespeed-go"
// Simple usage
output, err := wavespeed.Run(
"wavespeed-ai/z-image/turbo",
map[string]any{"prompt": "Cat"},
)
if err != nil {
log.Fatal(err)
}
fmt.Println(output["outputs"].([]any)[0])
// With options
output, err := wavespeed.Run(
"wavespeed-ai/z-image/turbo",
map[string]any{"prompt": "Cat"},
wavespeed.WithSyncMode(true),
wavespeed.WithTimeout(60),
)
func Upload ¶ added in v0.2.0
func Upload(file string, opts ...UploadOption) (string, error)
Upload uploads a file to WaveSpeed.
Args:
- file: File path string to upload.
- opts: Optional upload options (WithUploadTimeout, etc.)
Returns:
- URL of the uploaded file.
Example:
import "github.com/WaveSpeedAI/wavespeed-go"
// Simple usage
url, err := wavespeed.Upload("/path/to/image.png")
if err != nil {
log.Fatal(err)
}
fmt.Println(url)
// With timeout
url, err := wavespeed.Upload("/path/to/image.png", wavespeed.WithUploadTimeout(30))
Types ¶
type APIConfig ¶ added in v0.2.0
type APIConfig struct {
// Authentication
APIKey string
// API base URL
BaseURL string
// Connection timeout in seconds
ConnectionTimeout float64
// Total API call timeout in seconds
Timeout float64
// Maximum number of retries for the entire operation (task-level retries)
MaxRetries int
// Maximum number of retries for individual HTTP requests (connection errors, timeouts)
MaxConnectionRetries int
// Base interval between retries in seconds (actual delay = RetryInterval * attempt)
RetryInterval float64
}
APIConfig holds API client configuration options.
type UploadOption ¶ added in v0.2.0
type UploadOption = api.UploadOption
UploadOption configures optional parameters for Upload.
Click to show internal directories.
Click to hide internal directories.