Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 69 additions & 113 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,163 +1,119 @@
# openapi-java-client
<div align="center">
<a href="https://wavespeed.ai" target="_blank" rel="noopener noreferrer">
<img src="https://raw.githubusercontent.com/WaveSpeedAI/waverless/main/docs/images/wavespeed-dark-logo.png" alt="WaveSpeedAI logo" width="200"/>
</a>

WaveSpeed AI API
- API version: 0.0.1
- Build date: 2025-04-07T16:39:33.625926313+08:00[Asia/Shanghai]
- Generator version: 7.10.0
<h1>WaveSpeedAI Java SDK</h1>

API for generating images using WaveSpeed AI
<p>
<strong>Official Java SDK for the WaveSpeedAI inference platform</strong>
</p>

<p>
<a href="https://wavespeed.ai" target="_blank" rel="noopener noreferrer">🌐 Visit wavespeed.ai</a> •
<a href="https://wavespeed.ai/docs">📖 Documentation</a> •
<a href="https://github.com/WaveSpeedAI/client-java/issues">💬 Issues</a>
</p>
</div>

*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)*


## Requirements

Building the API client library requires:
1. Java 1.8+
2. Maven (3.8.3+)/Gradle (7.2+)
---

## Installation

To install the API client library to your local Maven repository, simply execute:

```shell
mvn clean install
```

To deploy it to a remote Maven repository instead, configure the settings of the repository and execute:

```shell
mvn clean deploy
```

Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information.
### Maven

### Maven users

Add this dependency to your project's POM:
Add this dependency to your project's `pom.xml`:

```xml
<dependency>
<groupId>ai.wavespeed.maven</groupId>
<artifactId>wavespeed-client</artifactId>
<version>0.0.1</version>
<scope>compile</scope>
</dependency>
```

### Gradle users
### Gradle

Add this dependency to your project's build file:
Add this dependency to your project's `build.gradle`:

```groovy
repositories {
mavenCentral() // Needed if the 'openapi-java-client' jar has been published to maven central.
mavenLocal() // Needed if the 'openapi-java-client' jar has been published to the local maven repo.
}

dependencies {
implementation "ai.wavespeed.maven:wavespeed-client:0.0.1"
}
```

### Others

At first generate the JAR by executing:

```shell
mvn clean package
dependencies {
implementation "ai.wavespeed.maven:wavespeed-client:0.0.1"
}
```

Then manually install the following JARs:
## API Client

* `target/wavespeed-client-0.0.1.jar`
* `target/lib/*.jar`

## Getting Started

Please follow the [installation](#installation) instruction and execute the following Java code:
Run WaveSpeed AI models with a simple API:

```java
package ai.wavespeed.client;

import ai.wavespeed.client.WaveSpeed;
import ai.wavespeed.openapi.client.ApiException;
import ai.wavespeed.openapi.client.model.Prediction;

import java.util.HashMap;
import java.util.Map;

public class Main {
public static void main(String[] args) throws InterruptedException {
WaveSpeed waveSpeed = new WaveSpeed("your-api-key");
Map<String, Object> input = new HashMap<String, Object>();
input.put("enable_base64_output", true);
input.put("enable_safety_checker", true);
input.put("guidance_scale", 3.5);
input.put("num_images", 1);
input.put("num_inference_steps", 28);
input.put("prompt", "Girl in red dress, hilltop, white deer, rabbits, sunset, japanese anime style");
input.put("seed", -1);
input.put("size", "1024*1024");
input.put("strength", 0.8);

try {
System.out.println(input);
Prediction prediction = waveSpeed.run("wavespeed-ai/flux-dev", input);
System.out.println(prediction);

Prediction prediction2 = waveSpeed.create("wavespeed-ai/flux-dev", input);
while (prediction2.getStatus() != Prediction.StatusEnum.COMPLETED && prediction2.getStatus() != Prediction.StatusEnum.FAILED) {
Thread.sleep(2000);
System.out.println("query status: " + prediction2.getStatus());
prediction2 = waveSpeed.getPrediction(prediction2.getId());
}
System.out.println(prediction2);
} catch (ApiException e) {
throw new RuntimeException(e);
}
}
}
WaveSpeed client = new WaveSpeed("your-api-key");
Map<String, Object> input = new HashMap<>();
input.put("prompt", "Cat");

try {
Prediction result = client.run("wavespeed-ai/z-image/turbo", input);
System.out.println(result.getOutputs().get(0)); // Output URL
} catch (ApiException e) {
e.printStackTrace();
}
```

## Documentation for API Endpoints

All URIs are relative to *https://api.wavespeed.ai/api/v2*
### Authentication

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*DefaultApi* | [**createPrediction**](docs/DefaultApi.md#createPrediction) | **POST** /{model_id} | Generate an image using the specified model
*DefaultApi* | [**getPrediction**](docs/DefaultApi.md#getPrediction) | **GET** /predictions/{predictionId}/result | Retrieve the result of a prediction
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"
```

## Documentation for Models
Or pass it directly:

- [CreatePrediction400Response](docs/CreatePrediction400Response.md)
- [CreatePrediction400ResponseData](docs/CreatePrediction400ResponseData.md)
- [CreatePrediction401Response](docs/CreatePrediction401Response.md)
- [CreatePrediction500Response](docs/CreatePrediction500Response.md)
- [Prediction](docs/Prediction.md)
- [PredictionResponse](docs/PredictionResponse.md)
- [PredictionUrls](docs/PredictionUrls.md)
```java
WaveSpeed client = new WaveSpeed("your-api-key");
```

### Options

<a id="documentation-for-authorization"></a>
## Documentation for Authorization
```java
// Custom poll interval and timeout
WaveSpeed client = new WaveSpeed("your-api-key", 1.0, 120.0); // pollInterval, timeoutSeconds

// Or set via environment variables
// WAVESPEED_POLL_INTERVAL=1.0
// WAVESPEED_TIMEOUT=120.0
```

Authentication schemes defined for the API:
<a id="bearerAuth"></a>
### bearerAuth
### Upload Files

- **Type**: HTTP Bearer Token authentication
Upload images, videos, or audio files:

```java
import ai.wavespeed.client.WaveSpeed;
import ai.wavespeed.openapi.client.ApiException;

## Recommendation
WaveSpeed client = new WaveSpeed("your-api-key");

It's recommended to create an instance of `WaveSpeed` per thread in a multithreaded environment to avoid any potential issues.
try {
String url = client.upload("/path/to/image.png");
System.out.println(url);
} catch (ApiException e) {
e.printStackTrace();
}
```

## Author
## Requirements

- Java 1.8+
- Maven 3.6+ or Gradle 7.2+

## License

Apache 2.0
16 changes: 16 additions & 0 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,12 @@ components:
- https://openapi-generator.tech
- https://openapi-generator.tech
executionTime: 6.027456183070403
input:
key: ""
urls:
get: https://openapi-generator.tech
timings:
key: ""
has_nsfw_contents:
- true
- true
Expand Down Expand Up @@ -205,6 +209,14 @@ components:
executionTime:
description: model execution time
type: number
input:
additionalProperties: true
description: Input parameters for the prediction
type: object
timings:
additionalProperties: true
description: Timing information for the prediction execution
type: object
required:
- id
- status
Expand Down Expand Up @@ -258,8 +270,12 @@ components:
- https://openapi-generator.tech
- https://openapi-generator.tech
executionTime: 6.027456183070403
input:
key: ""
urls:
get: https://openapi-generator.tech
timings:
key: ""
has_nsfw_contents:
- true
- true
Expand Down
45 changes: 40 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<beanvalidation-version>2.0.2</beanvalidation-version>
<junit-version>5.10.3</junit-version>
<junit-platform-runner.version>1.10.0</junit-platform-runner.version>
<mockwebserver-version>4.12.0</mockwebserver-version>
<jakarta.ws.rs-api-version>2.1.6</jakarta.ws.rs-api-version>
<jsr311-api-version>1.1.1</jsr311-api-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -111,13 +112,19 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-version}</version>
<!-- <scope>test</scope>-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit-platform-runner.version}</version>
<!-- <scope>test</scope>-->
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>${mockwebserver-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down Expand Up @@ -223,6 +230,34 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-version}</version>
</dependency>
</dependencies>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/DefaultApiTest.java</exclude>
<exclude>**/*ResponseTest.java</exclude>
<exclude>**/*UrlsTest.java</exclude>
</excludes>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/ai/wavespeed/client/Options.java

This file was deleted.

Loading