Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // WithAPIKey sets the API key for the client. WithAPIKey = api.WithAPIKey // WithBaseURL sets the base URL for the client. WithBaseURL = api.WithBaseURL // WithClientName sets the client name reported in the X-Client-Name header. WithClientName = api.WithClientName // WithConnectionTimeout sets the connection timeout in seconds. WithConnectionTimeout = api.WithConnectionTimeout // WithClientMaxRetries sets the maximum number of task-level retries. WithClientMaxRetries = api.WithClientMaxRetries // WithMaxConnectionRetries sets the maximum number of HTTP connection retries. WithMaxConnectionRetries = api.WithMaxConnectionRetries // WithRetryInterval sets the base interval between retries in seconds. WithRetryInterval = api.WithRetryInterval )
Client option constructors
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 )
Run option constructors
var API = api.API
API is the global API configuration instance. It is shared with the api subpackage: values set here are picked up as defaults by NewClient and by the package-level Run/Upload helpers.
var NewClient = api.NewClient
NewClient creates a new WaveSpeed API client with optional configuration. It is re-exported from the api subpackage so users never need to import it:
client := wavespeed.NewClient(wavespeed.WithAPIKey("your-api-key"))
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 ClientOption ¶ added in v0.2.4
type ClientOption = api.ClientOption
ClientOption configures a Client created with NewClient.
type RunNoThrowResult ¶ added in v0.2.4
type RunNoThrowResult = api.RunNoThrowResult
RunNoThrowResult is the result of the Client.RunNoThrow method.
type SubmissionError ¶ added in v0.2.4
type SubmissionError = api.SubmissionError
SubmissionError indicates that a prediction submission POST failed without a definitive response. The task may or may not have been created, so the SDK never retries the submission POST automatically.
type UploadOption ¶ added in v0.2.0
type UploadOption = api.UploadOption
UploadOption configures optional parameters for Upload.