wavespeed 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export interface PredictionUrls {
17
17
  export interface RequestOptions extends RequestInit {
18
18
  timeout?: number;
19
19
  maxRetries?: number;
20
+ webhook?: string;
20
21
  }
21
22
  /**
22
23
  * Prediction model representing an image generation job
package/dist/index.js CHANGED
@@ -90,8 +90,8 @@ class WaveSpeed {
90
90
  if (options.baseUrl) {
91
91
  this.baseUrl = options.baseUrl;
92
92
  }
93
- this.pollInterval = options.pollInterval || Number(getEnvVar('WAVESPEED_POLL_INTERVAL')) || 1;
94
- this.timeout = options.timeout || Number(getEnvVar('WAVESPEED_TIMEOUT')) || 60;
93
+ this.pollInterval = options.pollInterval || Number(getEnvVar('WAVESPEED_POLL_INTERVAL')) || 0.5;
94
+ this.timeout = options.timeout || Number(getEnvVar('WAVESPEED_TIMEOUT')) || 120;
95
95
  }
96
96
  /**
97
97
  * Fetch with timeout support
@@ -198,7 +198,12 @@ class WaveSpeed {
198
198
  * @param options Additional fetch options
199
199
  */
200
200
  async create(modelId, input, options) {
201
- const response = await this.fetchWithTimeout(`${modelId}`, {
201
+ // Build URL with webhook if provided in options
202
+ let url = `${modelId}`;
203
+ if (options === null || options === void 0 ? void 0 : options.webhook) {
204
+ url += `?webhook=${options.webhook}`;
205
+ }
206
+ const response = await this.fetchWithTimeout(url, {
202
207
  method: 'POST',
203
208
  body: JSON.stringify(input),
204
209
  ...options
@@ -208,6 +213,9 @@ class WaveSpeed {
208
213
  throw new Error(`Failed to create prediction: ${response.status} ${errorText}`);
209
214
  }
210
215
  const data = await response.json();
216
+ if (data.code !== 200) {
217
+ throw new Error(`Failed to create prediction: ${data.code} ${data}`);
218
+ }
211
219
  return new Prediction(data.data, this);
212
220
  }
213
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wavespeed",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "WaveSpeed Client SDK for Wavespeed API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",