@curvet/sdk 0.1.0 → 0.2.1

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.cts CHANGED
@@ -29,7 +29,7 @@ interface FetchResponse {
29
29
  interface FetchInit {
30
30
  method?: string;
31
31
  headers?: Record<string, string>;
32
- body?: string;
32
+ body?: string | FormData;
33
33
  signal?: AbortSignal;
34
34
  }
35
35
  /** Injectable fetch implementation (defaults to global fetch on Node 18+). */
@@ -173,6 +173,17 @@ interface VideoGenerateParams {
173
173
  resolution?: string;
174
174
  [key: string]: unknown;
175
175
  }
176
+ interface AudioGenerateParams {
177
+ model: ModelId;
178
+ prompt: string;
179
+ voice?: string;
180
+ [key: string]: unknown;
181
+ }
182
+ interface ThreeDGenerateParams {
183
+ model: ModelId;
184
+ prompt: string;
185
+ [key: string]: unknown;
186
+ }
176
187
  interface PollOptions {
177
188
  /** Poll interval in ms (default 2500). */
178
189
  pollIntervalMs?: number;
@@ -211,32 +222,46 @@ declare class Job {
211
222
  wait(opts?: PollOptions): Promise<MediaJob>;
212
223
  }
213
224
 
225
+ interface MediaParamsBase {
226
+ model: string;
227
+ prompt: string;
228
+ [key: string]: unknown;
229
+ }
214
230
  /**
215
- * Video generation. Backed by an async job queue: `generate()` submits and
216
- * polls to completion (the common case); `submit()` fires and returns the job
217
- * handle for manual polling.
231
+ * Generic engine for the async media endpoints (video / audio / 3d). They all
232
+ * enqueue the same server-side job queue, so they share one implementation
233
+ * parameterized by `path` and request param type.
218
234
  *
219
- * The same implementation backs audio and 3D (v1.1) via the `path` arg.
235
+ * `generate()` submits and polls to completion; `submit()` fires without polling.
220
236
  */
221
- declare class Video {
222
- private client;
223
- private defaults;
224
- private path;
225
- constructor(client: HttpClient, defaults: JobDefaults, path?: string);
226
- /**
227
- * Submit a job WITHOUT polling. Returns once the server responds — either the
228
- * 200 fast-path (already done) or a 202 with a jobId.
229
- *
230
- * The media POST long-polls server-side and can block well past a normal
231
- * request timeout, so we default its timeout to the poll budget and disable
232
- * auto-retry (a retried POST would enqueue a duplicate, double-charged job).
233
- */
234
- submit(params: VideoGenerateParams, options?: RequestOptions): Promise<MediaJob>;
237
+ declare class MediaResource<P extends MediaParamsBase> {
238
+ protected client: HttpClient;
239
+ protected defaults: JobDefaults;
240
+ protected path: string;
241
+ constructor(client: HttpClient, defaults: JobDefaults, path: string);
235
242
  /**
236
- * Submit and resolve to the finished media. Handles the 200-vs-202 split and
237
- * polls `/jobs/:id` internally. Throws JobFailedError / JobTimeoutError.
243
+ * Submit WITHOUT polling. The media POST long-polls server-side and can block
244
+ * well past a normal request timeout, so we default its timeout to the poll
245
+ * budget and disable auto-retry (a retried POST would enqueue a duplicate job).
238
246
  */
239
- generate(params: VideoGenerateParams, options?: RequestOptions & PollOptions): Promise<MediaJob>;
247
+ submit(params: P, options?: RequestOptions): Promise<MediaJob>;
248
+ /** Submit and resolve to the finished media (auto-polls /jobs/:id). */
249
+ generate(params: P, options?: RequestOptions & PollOptions): Promise<MediaJob>;
250
+ }
251
+
252
+ /** Video generation (async). `curvet.video.generate(...)` auto-polls to completion. */
253
+ declare class Video extends MediaResource<VideoGenerateParams> {
254
+ constructor(client: HttpClient, defaults: JobDefaults);
255
+ }
256
+
257
+ /** Audio generation (async). `curvet.audio.generate(...)` auto-polls to completion. */
258
+ declare class Audio extends MediaResource<AudioGenerateParams> {
259
+ constructor(client: HttpClient, defaults: JobDefaults);
260
+ }
261
+
262
+ /** 3D model generation (async). `curvet.threeD.generate(...)` auto-polls to completion. */
263
+ declare class ThreeD extends MediaResource<ThreeDGenerateParams> {
264
+ constructor(client: HttpClient, defaults: JobDefaults);
240
265
  }
241
266
 
242
267
  interface ModelsListOptions extends RequestOptions {
@@ -285,11 +310,115 @@ declare class Balance {
285
310
  get(options?: RequestOptions): Promise<BalanceInfo>;
286
311
  }
287
312
 
313
+ interface AnalyticsParams extends RequestOptions {
314
+ /** ISO 8601 start date. */
315
+ startDate?: string;
316
+ /** ISO 8601 end date. */
317
+ endDate?: string;
318
+ }
319
+ interface AnalyticsResult {
320
+ totalRequests?: number;
321
+ totalCost?: number;
322
+ requestsByModel?: Record<string, number>;
323
+ requestsByCategory?: Record<string, number>;
324
+ [key: string]: unknown;
325
+ }
326
+ declare class Analytics {
327
+ private client;
328
+ constructor(client: HttpClient);
329
+ /** Usage analytics for the app, optionally bounded by a date range. */
330
+ get(params?: AnalyticsParams): Promise<AnalyticsResult>;
331
+ }
332
+
333
+ interface WorkflowRunParams {
334
+ /** Input values for the workflow. */
335
+ inputs?: Record<string, unknown>;
336
+ /** Optional file inputs, keyed by the workflow's file field name. */
337
+ files?: Record<string, Blob>;
338
+ /** Include the full execution state in the response (default true server-side). */
339
+ includeFullState?: boolean;
340
+ }
341
+ interface WorkflowRunResult {
342
+ success: boolean;
343
+ [key: string]: unknown;
344
+ }
345
+ declare class Workflows {
346
+ private client;
347
+ constructor(client: HttpClient);
348
+ /**
349
+ * Execute a visual-builder workflow by id. Sends JSON when there are no file
350
+ * inputs, multipart/form-data when files are provided. Not auto-retried (a
351
+ * workflow run executes and may consume credits).
352
+ */
353
+ run(id: string, params?: WorkflowRunParams, options?: RequestOptions): Promise<WorkflowRunResult>;
354
+ }
355
+
356
+ interface FoodItem {
357
+ [key: string]: unknown;
358
+ }
359
+ /**
360
+ * Indian Food Dataset API. Mounted as a sibling of the playground under
361
+ * `/api/v1/food`, so it uses the v1-root HTTP client. Requires the app to have
362
+ * Food API access enabled.
363
+ */
364
+ declare class Food {
365
+ private client;
366
+ constructor(client: HttpClient);
367
+ /** List dishes (default limit 20). */
368
+ list(opts?: {
369
+ limit?: number;
370
+ } & RequestOptions): Promise<FoodItem[]>;
371
+ /** Full-text search for dishes. */
372
+ search(query: string, opts?: {
373
+ limit?: number;
374
+ } & RequestOptions): Promise<FoodItem[]>;
375
+ /** Natural-language dish recommendations. */
376
+ recommendations(prompt: string, options?: RequestOptions): Promise<FoodItem[]>;
377
+ }
378
+
379
+ interface SttParams {
380
+ /** The audio to transcribe. */
381
+ audio: Blob | Uint8Array | ArrayBuffer;
382
+ /** File name for the upload (default "audio"). */
383
+ filename?: string;
384
+ provider?: "elevenlabs" | "deepinfra" | (string & {});
385
+ /** ASR model id (provider-specific; optional). */
386
+ model?: string;
387
+ prompt?: string;
388
+ /** ISO 639-1 language hint. */
389
+ languageCode?: string;
390
+ allowFallback?: boolean;
391
+ }
392
+ interface SttResult {
393
+ success: boolean;
394
+ text: string;
395
+ languageCode?: string;
396
+ segments?: Array<{
397
+ start: number;
398
+ end: number;
399
+ text: string;
400
+ }>;
401
+ provider?: string;
402
+ creditsCharged?: number;
403
+ creditsRemaining?: number;
404
+ [key: string]: unknown;
405
+ }
406
+ /**
407
+ * Public speech-to-text. Mounted as a sibling of the playground under
408
+ * `/api/v1/voice`, so it uses the v1-root HTTP client. Multipart upload; not
409
+ * auto-retried (it consumes credits).
410
+ */
411
+ declare class Voice {
412
+ private client;
413
+ constructor(client: HttpClient);
414
+ stt(params: SttParams, options?: RequestOptions): Promise<SttResult>;
415
+ }
416
+
288
417
  declare const DEFAULT_BASE_URL = "https://curvet.ai/api/v1/playground";
289
418
  interface CurvetOptions {
290
419
  /** Your app key. Falls back to the CURVET_APP_KEY env var. */
291
420
  appKey?: string;
292
- /** Override the gateway base URL (defaults to production). */
421
+ /** Override the playground base URL (defaults to production). */
293
422
  baseURL?: string;
294
423
  /** Per-request timeout in ms (default 60000). */
295
424
  timeout?: number;
@@ -317,9 +446,15 @@ declare class Curvet {
317
446
  readonly chat: Chat;
318
447
  readonly image: Images;
319
448
  readonly video: Video;
449
+ readonly audio: Audio;
450
+ readonly threeD: ThreeD;
320
451
  readonly jobs: Jobs;
321
452
  readonly models: Models;
322
453
  readonly balance: Balance;
454
+ readonly analytics: Analytics;
455
+ readonly workflows: Workflows;
456
+ readonly food: Food;
457
+ readonly voice: Voice;
323
458
  constructor(options?: CurvetOptions);
324
459
  }
325
460
 
@@ -377,4 +512,4 @@ declare class JobTimeoutError extends CurvetError {
377
512
  constructor(message: string, jobId: string, opts?: CurvetErrorOptions);
378
513
  }
379
514
 
380
- export { APIError, AuthError, BadRequestError, Balance, type BalanceInfo, Chat, type ChatCreateParams, type ChatMessage, type ChatResponse, type ChatRole, ConnectionError, Curvet, CurvetError, type CurvetErrorOptions, type CurvetOptions, DEFAULT_BASE_URL, type FetchLike, type ImageGenerateParams, type ImageResponse, Images, InsufficientBalanceError, Job, type JobDefaults, JobFailedError, type JobStatus, JobTimeoutError, Jobs, type KnownModelId, type MediaJob, type MediaKind, type ModelId, type ModelInfo, type ModelType, Models, type ModelsListOptions, NotFoundError, PermissionError, type PollOptions, RateLimitError, type RateLimits, type RequestOptions, type Usage, Video, type VideoGenerateParams };
515
+ export { APIError, Analytics, type AnalyticsParams, type AnalyticsResult, Audio, type AudioGenerateParams, AuthError, BadRequestError, Balance, type BalanceInfo, Chat, type ChatCreateParams, type ChatMessage, type ChatResponse, type ChatRole, ConnectionError, Curvet, CurvetError, type CurvetErrorOptions, type CurvetOptions, DEFAULT_BASE_URL, type FetchLike, Food, type FoodItem, type ImageGenerateParams, type ImageResponse, Images, InsufficientBalanceError, Job, type JobDefaults, JobFailedError, type JobStatus, JobTimeoutError, Jobs, type KnownModelId, type MediaJob, type MediaKind, type MediaParamsBase, MediaResource, type ModelId, type ModelInfo, type ModelType, Models, type ModelsListOptions, NotFoundError, PermissionError, type PollOptions, RateLimitError, type RateLimits, type RequestOptions, type SttParams, type SttResult, ThreeD, type ThreeDGenerateParams, type Usage, Video, type VideoGenerateParams, Voice, type WorkflowRunParams, type WorkflowRunResult, Workflows };
package/dist/index.d.ts CHANGED
@@ -29,7 +29,7 @@ interface FetchResponse {
29
29
  interface FetchInit {
30
30
  method?: string;
31
31
  headers?: Record<string, string>;
32
- body?: string;
32
+ body?: string | FormData;
33
33
  signal?: AbortSignal;
34
34
  }
35
35
  /** Injectable fetch implementation (defaults to global fetch on Node 18+). */
@@ -173,6 +173,17 @@ interface VideoGenerateParams {
173
173
  resolution?: string;
174
174
  [key: string]: unknown;
175
175
  }
176
+ interface AudioGenerateParams {
177
+ model: ModelId;
178
+ prompt: string;
179
+ voice?: string;
180
+ [key: string]: unknown;
181
+ }
182
+ interface ThreeDGenerateParams {
183
+ model: ModelId;
184
+ prompt: string;
185
+ [key: string]: unknown;
186
+ }
176
187
  interface PollOptions {
177
188
  /** Poll interval in ms (default 2500). */
178
189
  pollIntervalMs?: number;
@@ -211,32 +222,46 @@ declare class Job {
211
222
  wait(opts?: PollOptions): Promise<MediaJob>;
212
223
  }
213
224
 
225
+ interface MediaParamsBase {
226
+ model: string;
227
+ prompt: string;
228
+ [key: string]: unknown;
229
+ }
214
230
  /**
215
- * Video generation. Backed by an async job queue: `generate()` submits and
216
- * polls to completion (the common case); `submit()` fires and returns the job
217
- * handle for manual polling.
231
+ * Generic engine for the async media endpoints (video / audio / 3d). They all
232
+ * enqueue the same server-side job queue, so they share one implementation
233
+ * parameterized by `path` and request param type.
218
234
  *
219
- * The same implementation backs audio and 3D (v1.1) via the `path` arg.
235
+ * `generate()` submits and polls to completion; `submit()` fires without polling.
220
236
  */
221
- declare class Video {
222
- private client;
223
- private defaults;
224
- private path;
225
- constructor(client: HttpClient, defaults: JobDefaults, path?: string);
226
- /**
227
- * Submit a job WITHOUT polling. Returns once the server responds — either the
228
- * 200 fast-path (already done) or a 202 with a jobId.
229
- *
230
- * The media POST long-polls server-side and can block well past a normal
231
- * request timeout, so we default its timeout to the poll budget and disable
232
- * auto-retry (a retried POST would enqueue a duplicate, double-charged job).
233
- */
234
- submit(params: VideoGenerateParams, options?: RequestOptions): Promise<MediaJob>;
237
+ declare class MediaResource<P extends MediaParamsBase> {
238
+ protected client: HttpClient;
239
+ protected defaults: JobDefaults;
240
+ protected path: string;
241
+ constructor(client: HttpClient, defaults: JobDefaults, path: string);
235
242
  /**
236
- * Submit and resolve to the finished media. Handles the 200-vs-202 split and
237
- * polls `/jobs/:id` internally. Throws JobFailedError / JobTimeoutError.
243
+ * Submit WITHOUT polling. The media POST long-polls server-side and can block
244
+ * well past a normal request timeout, so we default its timeout to the poll
245
+ * budget and disable auto-retry (a retried POST would enqueue a duplicate job).
238
246
  */
239
- generate(params: VideoGenerateParams, options?: RequestOptions & PollOptions): Promise<MediaJob>;
247
+ submit(params: P, options?: RequestOptions): Promise<MediaJob>;
248
+ /** Submit and resolve to the finished media (auto-polls /jobs/:id). */
249
+ generate(params: P, options?: RequestOptions & PollOptions): Promise<MediaJob>;
250
+ }
251
+
252
+ /** Video generation (async). `curvet.video.generate(...)` auto-polls to completion. */
253
+ declare class Video extends MediaResource<VideoGenerateParams> {
254
+ constructor(client: HttpClient, defaults: JobDefaults);
255
+ }
256
+
257
+ /** Audio generation (async). `curvet.audio.generate(...)` auto-polls to completion. */
258
+ declare class Audio extends MediaResource<AudioGenerateParams> {
259
+ constructor(client: HttpClient, defaults: JobDefaults);
260
+ }
261
+
262
+ /** 3D model generation (async). `curvet.threeD.generate(...)` auto-polls to completion. */
263
+ declare class ThreeD extends MediaResource<ThreeDGenerateParams> {
264
+ constructor(client: HttpClient, defaults: JobDefaults);
240
265
  }
241
266
 
242
267
  interface ModelsListOptions extends RequestOptions {
@@ -285,11 +310,115 @@ declare class Balance {
285
310
  get(options?: RequestOptions): Promise<BalanceInfo>;
286
311
  }
287
312
 
313
+ interface AnalyticsParams extends RequestOptions {
314
+ /** ISO 8601 start date. */
315
+ startDate?: string;
316
+ /** ISO 8601 end date. */
317
+ endDate?: string;
318
+ }
319
+ interface AnalyticsResult {
320
+ totalRequests?: number;
321
+ totalCost?: number;
322
+ requestsByModel?: Record<string, number>;
323
+ requestsByCategory?: Record<string, number>;
324
+ [key: string]: unknown;
325
+ }
326
+ declare class Analytics {
327
+ private client;
328
+ constructor(client: HttpClient);
329
+ /** Usage analytics for the app, optionally bounded by a date range. */
330
+ get(params?: AnalyticsParams): Promise<AnalyticsResult>;
331
+ }
332
+
333
+ interface WorkflowRunParams {
334
+ /** Input values for the workflow. */
335
+ inputs?: Record<string, unknown>;
336
+ /** Optional file inputs, keyed by the workflow's file field name. */
337
+ files?: Record<string, Blob>;
338
+ /** Include the full execution state in the response (default true server-side). */
339
+ includeFullState?: boolean;
340
+ }
341
+ interface WorkflowRunResult {
342
+ success: boolean;
343
+ [key: string]: unknown;
344
+ }
345
+ declare class Workflows {
346
+ private client;
347
+ constructor(client: HttpClient);
348
+ /**
349
+ * Execute a visual-builder workflow by id. Sends JSON when there are no file
350
+ * inputs, multipart/form-data when files are provided. Not auto-retried (a
351
+ * workflow run executes and may consume credits).
352
+ */
353
+ run(id: string, params?: WorkflowRunParams, options?: RequestOptions): Promise<WorkflowRunResult>;
354
+ }
355
+
356
+ interface FoodItem {
357
+ [key: string]: unknown;
358
+ }
359
+ /**
360
+ * Indian Food Dataset API. Mounted as a sibling of the playground under
361
+ * `/api/v1/food`, so it uses the v1-root HTTP client. Requires the app to have
362
+ * Food API access enabled.
363
+ */
364
+ declare class Food {
365
+ private client;
366
+ constructor(client: HttpClient);
367
+ /** List dishes (default limit 20). */
368
+ list(opts?: {
369
+ limit?: number;
370
+ } & RequestOptions): Promise<FoodItem[]>;
371
+ /** Full-text search for dishes. */
372
+ search(query: string, opts?: {
373
+ limit?: number;
374
+ } & RequestOptions): Promise<FoodItem[]>;
375
+ /** Natural-language dish recommendations. */
376
+ recommendations(prompt: string, options?: RequestOptions): Promise<FoodItem[]>;
377
+ }
378
+
379
+ interface SttParams {
380
+ /** The audio to transcribe. */
381
+ audio: Blob | Uint8Array | ArrayBuffer;
382
+ /** File name for the upload (default "audio"). */
383
+ filename?: string;
384
+ provider?: "elevenlabs" | "deepinfra" | (string & {});
385
+ /** ASR model id (provider-specific; optional). */
386
+ model?: string;
387
+ prompt?: string;
388
+ /** ISO 639-1 language hint. */
389
+ languageCode?: string;
390
+ allowFallback?: boolean;
391
+ }
392
+ interface SttResult {
393
+ success: boolean;
394
+ text: string;
395
+ languageCode?: string;
396
+ segments?: Array<{
397
+ start: number;
398
+ end: number;
399
+ text: string;
400
+ }>;
401
+ provider?: string;
402
+ creditsCharged?: number;
403
+ creditsRemaining?: number;
404
+ [key: string]: unknown;
405
+ }
406
+ /**
407
+ * Public speech-to-text. Mounted as a sibling of the playground under
408
+ * `/api/v1/voice`, so it uses the v1-root HTTP client. Multipart upload; not
409
+ * auto-retried (it consumes credits).
410
+ */
411
+ declare class Voice {
412
+ private client;
413
+ constructor(client: HttpClient);
414
+ stt(params: SttParams, options?: RequestOptions): Promise<SttResult>;
415
+ }
416
+
288
417
  declare const DEFAULT_BASE_URL = "https://curvet.ai/api/v1/playground";
289
418
  interface CurvetOptions {
290
419
  /** Your app key. Falls back to the CURVET_APP_KEY env var. */
291
420
  appKey?: string;
292
- /** Override the gateway base URL (defaults to production). */
421
+ /** Override the playground base URL (defaults to production). */
293
422
  baseURL?: string;
294
423
  /** Per-request timeout in ms (default 60000). */
295
424
  timeout?: number;
@@ -317,9 +446,15 @@ declare class Curvet {
317
446
  readonly chat: Chat;
318
447
  readonly image: Images;
319
448
  readonly video: Video;
449
+ readonly audio: Audio;
450
+ readonly threeD: ThreeD;
320
451
  readonly jobs: Jobs;
321
452
  readonly models: Models;
322
453
  readonly balance: Balance;
454
+ readonly analytics: Analytics;
455
+ readonly workflows: Workflows;
456
+ readonly food: Food;
457
+ readonly voice: Voice;
323
458
  constructor(options?: CurvetOptions);
324
459
  }
325
460
 
@@ -377,4 +512,4 @@ declare class JobTimeoutError extends CurvetError {
377
512
  constructor(message: string, jobId: string, opts?: CurvetErrorOptions);
378
513
  }
379
514
 
380
- export { APIError, AuthError, BadRequestError, Balance, type BalanceInfo, Chat, type ChatCreateParams, type ChatMessage, type ChatResponse, type ChatRole, ConnectionError, Curvet, CurvetError, type CurvetErrorOptions, type CurvetOptions, DEFAULT_BASE_URL, type FetchLike, type ImageGenerateParams, type ImageResponse, Images, InsufficientBalanceError, Job, type JobDefaults, JobFailedError, type JobStatus, JobTimeoutError, Jobs, type KnownModelId, type MediaJob, type MediaKind, type ModelId, type ModelInfo, type ModelType, Models, type ModelsListOptions, NotFoundError, PermissionError, type PollOptions, RateLimitError, type RateLimits, type RequestOptions, type Usage, Video, type VideoGenerateParams };
515
+ export { APIError, Analytics, type AnalyticsParams, type AnalyticsResult, Audio, type AudioGenerateParams, AuthError, BadRequestError, Balance, type BalanceInfo, Chat, type ChatCreateParams, type ChatMessage, type ChatResponse, type ChatRole, ConnectionError, Curvet, CurvetError, type CurvetErrorOptions, type CurvetOptions, DEFAULT_BASE_URL, type FetchLike, Food, type FoodItem, type ImageGenerateParams, type ImageResponse, Images, InsufficientBalanceError, Job, type JobDefaults, JobFailedError, type JobStatus, JobTimeoutError, Jobs, type KnownModelId, type MediaJob, type MediaKind, type MediaParamsBase, MediaResource, type ModelId, type ModelInfo, type ModelType, Models, type ModelsListOptions, NotFoundError, PermissionError, type PollOptions, RateLimitError, type RateLimits, type RequestOptions, type SttParams, type SttResult, ThreeD, type ThreeDGenerateParams, type Usage, Video, type VideoGenerateParams, Voice, type WorkflowRunParams, type WorkflowRunResult, Workflows };