|
1 | | -<div align="center"> |
2 | | - <a href="https://wavespeed.ai" target="_blank" rel="noopener noreferrer"> |
3 | | - <img src="https://raw.githubusercontent.com/WaveSpeedAI/waverless/main/docs/images/wavespeed-dark-logo.png" alt="WaveSpeedAI logo" width="200"/> |
4 | | - </a> |
| 1 | +# openapi-java-client |
5 | 2 |
|
6 | | - <h1>WaveSpeedAI Java SDK</h1> |
| 3 | +WaveSpeed AI API |
| 4 | +- API version: 0.1.0-SNAPSHOT |
| 5 | + - Build date: 2025-12-11T14:56:51.031680200+08:00[Asia/Shanghai] |
| 6 | + - Generator version: 7.10.0 |
7 | 7 |
|
8 | | - <p> |
9 | | - <strong>Official Java SDK for the WaveSpeedAI inference platform</strong> |
10 | | - </p> |
| 8 | +API for generating images using WaveSpeed AI |
11 | 9 |
|
12 | | - <p> |
13 | | - <a href="https://wavespeed.ai" target="_blank" rel="noopener noreferrer">🌐 Visit wavespeed.ai</a> • |
14 | | - <a href="https://wavespeed.ai/docs">📖 Documentation</a> • |
15 | | - <a href="https://github.com/WaveSpeedAI/wavespeed-java/issues">💬 Issues</a> |
16 | | - </p> |
17 | | -</div> |
18 | 10 |
|
19 | | ---- |
| 11 | +*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* |
| 12 | + |
| 13 | + |
| 14 | +## Requirements |
| 15 | + |
| 16 | +Building the API client library requires: |
| 17 | +1. Java 1.8+ |
| 18 | +2. Maven (3.8.3+)/Gradle (7.2+) |
20 | 19 |
|
21 | 20 | ## Installation |
22 | 21 |
|
23 | | -### Maven |
| 22 | +To install the API client library to your local Maven repository, simply execute: |
24 | 23 |
|
25 | | -Add this dependency to your project's `pom.xml`: |
| 24 | +```shell |
| 25 | +mvn clean install |
| 26 | +``` |
| 27 | + |
| 28 | +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: |
| 29 | + |
| 30 | +```shell |
| 31 | +mvn clean deploy |
| 32 | +``` |
| 33 | + |
| 34 | +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. |
| 35 | + |
| 36 | +### Maven users |
| 37 | + |
| 38 | +Add this dependency to your project's POM: |
26 | 39 |
|
27 | 40 | ```xml |
28 | 41 | <dependency> |
29 | | - <groupId>ai.wavespeed.maven</groupId> |
30 | | - <artifactId>wavespeed</artifactId> |
31 | | - <version>0.0.1</version> |
| 42 | + <groupId>org.openapitools</groupId> |
| 43 | + <artifactId>openapi-java-client</artifactId> |
| 44 | + <version>0.1.0-SNAPSHOT</version> |
| 45 | + <scope>compile</scope> |
32 | 46 | </dependency> |
33 | 47 | ``` |
34 | 48 |
|
35 | | -### Gradle |
| 49 | +### Gradle users |
36 | 50 |
|
37 | | -Add this dependency to your project's `build.gradle`: |
| 51 | +Add this dependency to your project's build file: |
38 | 52 |
|
39 | 53 | ```groovy |
40 | | -dependencies { |
41 | | - implementation "ai.wavespeed.maven:wavespeed:0.0.1" |
42 | | -} |
| 54 | + repositories { |
| 55 | + mavenCentral() // Needed if the 'openapi-java-client' jar has been published to maven central. |
| 56 | + mavenLocal() // Needed if the 'openapi-java-client' jar has been published to the local maven repo. |
| 57 | + } |
| 58 | +
|
| 59 | + dependencies { |
| 60 | + implementation "org.openapitools:openapi-java-client:0.1.0-SNAPSHOT" |
| 61 | + } |
43 | 62 | ``` |
44 | 63 |
|
45 | | -## API Client |
| 64 | +### Others |
46 | 65 |
|
47 | | -Run WaveSpeed AI models with a simple API: |
| 66 | +At first generate the JAR by executing: |
48 | 67 |
|
49 | | -```java |
50 | | -import ai.wavespeed.WaveSpeed; |
51 | | -import ai.wavespeed.openapi.client.model.Prediction; |
52 | | -import java.util.HashMap; |
53 | | -import java.util.Map; |
54 | | - |
55 | | -WaveSpeed client = new WaveSpeed("your-api-key"); |
56 | | -Map<String, Object> input = new HashMap<>(); |
57 | | -input.put("prompt", "Cat"); |
58 | | - |
59 | | -try { |
60 | | - Prediction result = client.run("wavespeed-ai/z-image/turbo", input); |
61 | | - System.out.println(result.getOutputs().get(0)); // Output URL |
62 | | -} catch (Exception e) { |
63 | | - e.printStackTrace(); |
64 | | -} |
| 68 | +```shell |
| 69 | +mvn clean package |
65 | 70 | ``` |
66 | 71 |
|
67 | | -### Authentication |
| 72 | +Then manually install the following JARs: |
68 | 73 |
|
69 | | -Set your API key via environment variable (You can get your API key from [https://wavespeed.ai/accesskey](https://wavespeed.ai/accesskey)): |
| 74 | +* `target/openapi-java-client-0.1.0-SNAPSHOT.jar` |
| 75 | +* `target/lib/*.jar` |
70 | 76 |
|
71 | | -```bash |
72 | | -export WAVESPEED_API_KEY="your-api-key" |
73 | | -``` |
| 77 | +## Getting Started |
74 | 78 |
|
75 | | -Or pass it directly: |
| 79 | +Please follow the [installation](#installation) instruction and execute the following Java code: |
76 | 80 |
|
77 | 81 | ```java |
78 | | -WaveSpeed client = new WaveSpeed("your-api-key"); |
79 | | -``` |
80 | 82 |
|
81 | | -### Options |
| 83 | +// Import classes: |
| 84 | +import ai.wavespeed.openapi.client.ApiClient; |
| 85 | +import ai.wavespeed.openapi.client.ApiException; |
| 86 | +import ai.wavespeed.openapi.client.Configuration; |
| 87 | +import ai.wavespeed.openapi.client.auth.*; |
| 88 | +import ai.wavespeed.openapi.client.model.*; |
| 89 | +import ai.wavespeed.openapi.client.api.DefaultApi; |
| 90 | + |
| 91 | +public class Example { |
| 92 | + public static void main(String[] args) { |
| 93 | + ApiClient defaultClient = Configuration.getDefaultApiClient(); |
| 94 | + defaultClient.setBasePath("https://api.wavespeed.ai/api/v2"); |
| 95 | + |
| 96 | + // Configure HTTP bearer authorization: bearerAuth |
| 97 | + HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth"); |
| 98 | + bearerAuth.setBearerToken("BEARER TOKEN"); |
| 99 | + |
| 100 | + DefaultApi apiInstance = new DefaultApi(defaultClient); |
| 101 | + String modelId = "modelId_example"; // String | The ID of the model to use for image generation |
| 102 | + Map<String, Object> requestBody = null; // Map<String, Object> | |
| 103 | + String webhook = "webhook_example"; // String | The URL to which the webhook will be sent |
| 104 | + try { |
| 105 | + PredictionResponse result = apiInstance.createPredictionData(modelId, requestBody, webhook); |
| 106 | + System.out.println(result); |
| 107 | + } catch (ApiException e) { |
| 108 | + System.err.println("Exception when calling DefaultApi#createPredictionData"); |
| 109 | + System.err.println("Status code: " + e.getCode()); |
| 110 | + System.err.println("Reason: " + e.getResponseBody()); |
| 111 | + System.err.println("Response headers: " + e.getResponseHeaders()); |
| 112 | + e.printStackTrace(); |
| 113 | + } |
| 114 | + } |
| 115 | +} |
82 | 116 |
|
83 | | -```java |
84 | | -// Custom poll interval and timeout (seconds) |
85 | | -WaveSpeed client = new WaveSpeed("your-api-key", 1.0, 36000.0); |
86 | 117 | ``` |
87 | 118 |
|
88 | | -### Upload Files |
| 119 | +## Documentation for API Endpoints |
89 | 120 |
|
90 | | -Upload images, videos, or audio files: |
| 121 | +All URIs are relative to *https://api.wavespeed.ai/api/v2* |
91 | 122 |
|
92 | | -```java |
93 | | -WaveSpeed client = new WaveSpeed("your-api-key"); |
| 123 | +Class | Method | HTTP request | Description |
| 124 | +------------ | ------------- | ------------- | ------------- |
| 125 | +*DefaultApi* | [**createPredictionData**](docs/DefaultApi.md#createPredictionData) | **POST** /{model_id} | Generate an image using the specified model |
| 126 | +*DefaultApi* | [**getPredictionData**](docs/DefaultApi.md#getPredictionData) | **GET** /predictions/{predictionId}/result | Retrieve the result of a prediction |
94 | 127 |
|
95 | | -try { |
96 | | - String url = client.upload("/path/to/image.png"); |
97 | | - System.out.println(url); |
98 | | -} catch (Exception e) { |
99 | | - e.printStackTrace(); |
100 | | -} |
101 | | -``` |
102 | 128 |
|
103 | | -## Environment Variables |
| 129 | +## Documentation for Models |
104 | 130 |
|
105 | | -### API Client |
| 131 | + - [CreatePredictionData400Response](docs/CreatePredictionData400Response.md) |
| 132 | + - [CreatePredictionData400ResponseData](docs/CreatePredictionData400ResponseData.md) |
| 133 | + - [CreatePredictionData401Response](docs/CreatePredictionData401Response.md) |
| 134 | + - [CreatePredictionData500Response](docs/CreatePredictionData500Response.md) |
| 135 | + - [Prediction](docs/Prediction.md) |
| 136 | + - [PredictionResponse](docs/PredictionResponse.md) |
| 137 | + - [PredictionUrls](docs/PredictionUrls.md) |
106 | 138 |
|
107 | | -| Variable | Description | |
108 | | -|----------|-------------| |
109 | | -| `WAVESPEED_API_KEY` | WaveSpeed API key | |
110 | | -| `WAVESPEED_BASE_URL` | API base URL without path (default: `https://api.wavespeed.ai`) | |
111 | | -| `WAVESPEED_POLL_INTERVAL` | Poll interval seconds for `run` (default: `1.0`) | |
112 | | -| `WAVESPEED_TIMEOUT` | Overall wait timeout seconds for `run` (default: `36000.0`) | |
113 | 139 |
|
114 | | -## Requirements |
| 140 | +<a id="documentation-for-authorization"></a> |
| 141 | +## Documentation for Authorization |
| 142 | + |
| 143 | + |
| 144 | +Authentication schemes defined for the API: |
| 145 | +<a id="bearerAuth"></a> |
| 146 | +### bearerAuth |
| 147 | + |
| 148 | +- **Type**: HTTP Bearer Token authentication |
| 149 | + |
| 150 | + |
| 151 | +## Recommendation |
| 152 | + |
| 153 | +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. |
| 154 | + |
| 155 | +## Author |
115 | 156 |
|
116 | | -- Java 1.8+ |
117 | | -- Maven 3.6+ or Gradle 7.2+ |
118 | 157 |
|
119 | | -## License |
120 | 158 |
|
121 | | -Apache 2.0 |
|
0 commit comments