An open API service indexing awesome lists of open source software.

https://github.com/wavespeedai/wavespeed-java

WaveSpeedAI Java Client — Official Java SDK for WaveSpeedAI inference platform. This library provides a clean, unified, and high-performance API and serverless integration layer for your Java applications. Effortlessly connect to all WaveSpeedAI models and inference services with zero infrastructure overhead.
https://github.com/wavespeedai/wavespeed-java

Last synced: 5 months ago
JSON representation

WaveSpeedAI Java Client — Official Java SDK for WaveSpeedAI inference platform. This library provides a clean, unified, and high-performance API and serverless integration layer for your Java applications. Effortlessly connect to all WaveSpeedAI models and inference services with zero infrastructure overhead.

Awesome Lists containing this project

README

          



WaveSpeedAI logo

WaveSpeedAI Java SDK


Official Java SDK for the WaveSpeedAI inference platform


🌐 Visit wavespeed.ai
📖 Documentation
💬 Issues


---

## Introduction

**WaveSpeedAI** Java Client — Official Java SDK for **WaveSpeedAI** inference platform. This library provides a clean, unified, and high-performance API for your Java applications.

## Installation

### Maven

```xml

ai.wavespeed
wavespeed-java-sdk
0.2.0

```

### Gradle

```gradle
implementation 'ai.wavespeed:wavespeed-java-sdk:0.2.0'
```

## API Client

Run WaveSpeed AI models with a simple API:

```java
import ai.wavespeed.Wavespeed;
import java.util.Map;

public class Example {
public static void main(String[] args) {
Map output = Wavespeed.run(
"wavespeed-ai/z-image/turbo",
Map.of("prompt", "Cat")
);

System.out.println(output.get("outputs")); // Output URL
}
}
```

### Authentication

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

```bash
export WAVESPEED_API_KEY="your-api-key"
```

Or pass it directly:

```java
import ai.wavespeed.api.Client;

Client client = new Client("your-api-key");
Map output = client.run(
"wavespeed-ai/z-image/turbo",
Map.of("prompt", "Cat")
);
```

### Options

```java
Map output = Wavespeed.run(
"wavespeed-ai/z-image/turbo",
Map.of("prompt", "Cat"),
36000.0, // timeout - Max wait time in seconds (default: 36000.0)
1.0, // pollInterval - Status check interval (default: 1.0)
false, // enableSyncMode - Single request mode, no polling (default: false)
null // maxRetries - Task-level retries (default: 0)
);
```

### 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.

```java
Map output = Wavespeed.run(
"wavespeed-ai/z-image/turbo",
Map.of("prompt", "Cat"),
true // enableSyncMode
);
```

### Retry Configuration

Configure retries at the client level:

```java
import ai.wavespeed.api.Client;

// Simple retry configuration
Client client = new Client(
"your-api-key",
3, // maxRetries - Task-level retries (default: 0)
5, // maxConnectionRetries - HTTP connection retries (default: 5)
1.0 // retryInterval - Base delay between retries in seconds (default: 1.0)
);
```

### Upload Files

Upload images, videos, or audio files:

```java
import ai.wavespeed.Wavespeed;

String url = Wavespeed.upload("/path/to/image.png");
System.out.println(url);
```

## Running Tests

```bash
# Run all tests
mvn test

# Run a single test file
mvn test -Dtest=ClientTest

# Run a specific test
mvn test -Dtest=ClientTest#testInitWithApiKey
```

## Environment Variables

### API Client

| Variable | Description |
|----------|-------------|
| `WAVESPEED_API_KEY` | WaveSpeed API key |

## License

MIT