Skip to content

WaveSpeedAI Go Client — Official Go SDK for WaveSpeedAI inference platform. This library provides a clean, type-safe, and high-performance API with seamless serverless integration for your applications. Built with Go's concurrency primitives, effortlessly connect to all WaveSpeedAI models and inference services with zero infrastructure overhead.

License

Notifications You must be signed in to change notification settings

WaveSpeedAI/wavespeed-go

Repository files navigation

WaveSpeedAI logo

WaveSpeedAI Go SDK

Official Go SDK for the WaveSpeedAI inference platform

🌐 Visit wavespeed.ai📖 Documentation💬 Issues


Installation

go get github.com/WaveSpeedAI/wavespeed-go

API Client

Run WaveSpeed AI models with a simple API:

import wavespeed "github.com/WaveSpeedAI/wavespeed-go"

client, err := wavespeed.NewClient("your-api-key")
if err != nil {
	log.Fatal(err)
}

output, err := client.Run("wavespeed-ai/z-image/turbo", map[string]any{
	"prompt": "Cat",
})
if err != nil {
	log.Fatal(err)
}

fmt.Println(output.Outputs[0])  // Output URL

Authentication

Set your API key via environment variable (You can get your API key from https://wavespeed.ai/accesskey):

export WAVESPEED_API_KEY="your-api-key"

Or pass it directly when creating the client:

client, err := wavespeed.NewClient("your-api-key")

Options

output, err := client.Run("wavespeed-ai/z-image/turbo", map[string]any{
	"prompt": "Cat",
}, &wavespeed.RunOptions{
	TimeoutSeconds:      36000, // Max wait time in seconds (default: 36000)
	PollIntervalSeconds: 1,     // Status check interval (default: 1)
	EnableSyncMode:      false, // Single request mode, no polling (default: false)
})

Sync Mode

Use EnableSyncMode: true for a single request that waits for the result (no polling).

Note: Not all models support sync mode. Check the model documentation for availability.

output, err := client.Run("wavespeed-ai/z-image/turbo", map[string]any{
	"prompt": "Cat",
}, &wavespeed.RunOptions{
	EnableSyncMode: true,
})

Retry Configuration

Configure retries at the client level:

client, err := wavespeed.NewClient("your-api-key", &wavespeed.ClientOptions{
	MaxRetries:           0, // Task-level retries (default: 0)
	MaxConnectionRetries: 5, // HTTP connection retries (default: 5)
	RetryInterval:        1, // Base delay between retries in seconds (default: 1)
})

Upload Files

Upload images, videos, or audio files:

url, err := client.Upload("/path/to/image.png")
if err != nil {
	log.Fatal(err)
}
fmt.Println(url)

Environment Variables

API Client

Variable Description
WAVESPEED_API_KEY WaveSpeed API key

License

MIT

About

WaveSpeedAI Go Client — Official Go SDK for WaveSpeedAI inference platform. This library provides a clean, type-safe, and high-performance API with seamless serverless integration for your applications. Built with Go's concurrency primitives, effortlessly connect to all WaveSpeedAI models and inference services with zero infrastructure overhead.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages