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.
- Host: GitHub
- URL: https://github.com/wavespeedai/wavespeed-java
- Owner: WaveSpeedAI
- License: mit
- Created: 2025-12-11T05:50:25.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-12-15T10:34:04.000Z (6 months ago)
- Last Synced: 2025-12-26T08:38:08.567Z (6 months ago)
- Language: Java
- Size: 55.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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