@visgate_ai/client 0.2.22 → 0.3.3

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
@@ -175,6 +175,103 @@ declare class Models {
175
175
  search(query: string, limit?: number): Promise<ModelsResponse>;
176
176
  }
177
177
 
178
+ /** Deployment management: /deployments endpoints */
179
+
180
+ interface DeploymentCreateOptions {
181
+ modelName?: string;
182
+ hfModelId?: string;
183
+ gpuTier?: string;
184
+ region?: string;
185
+ hfToken?: string;
186
+ runpodKey?: string;
187
+ webhookUrl?: string;
188
+ cacheScope?: "off" | "shared" | "private";
189
+ provider?: string;
190
+ task?: string;
191
+ userS3Url?: string;
192
+ userAwsAccessKeyId?: string;
193
+ userAwsSecretAccessKey?: string;
194
+ userAwsEndpointUrl?: string;
195
+ }
196
+ interface DeploymentInfo {
197
+ deploymentId: string;
198
+ modelId?: string | null;
199
+ status: string;
200
+ endpointUrl?: string | null;
201
+ provider?: string | null;
202
+ createdAt?: string | null;
203
+ gpuAllocated?: string | null;
204
+ modelVramGb?: number | null;
205
+ readyAt?: string | null;
206
+ error?: string | null;
207
+ }
208
+ interface DeploymentListResponse {
209
+ deployments: DeploymentInfo[];
210
+ }
211
+ interface DeploymentGpuInfo {
212
+ id: string;
213
+ displayName: string;
214
+ memoryGb: number;
215
+ secureCloud: boolean;
216
+ communityCloud: boolean;
217
+ bidPricePerHr?: number | null;
218
+ pricePerHr?: number | null;
219
+ }
220
+ interface DeploymentGpuListResponse {
221
+ gpus: DeploymentGpuInfo[];
222
+ }
223
+ interface DeploymentLogEntry {
224
+ timestamp: string;
225
+ level: string;
226
+ message: string;
227
+ }
228
+ interface DeploymentLogsResponse {
229
+ deploymentId: string;
230
+ logs: DeploymentLogEntry[];
231
+ }
232
+ interface DeploymentCostResponse {
233
+ deploymentId: string;
234
+ status: string;
235
+ gpuAllocated?: string | null;
236
+ hoursRunning?: number | null;
237
+ pricePerHourUsd?: number | null;
238
+ estimatedCostUsd?: number | null;
239
+ note?: string | null;
240
+ }
241
+ interface DeploymentRunRequest {
242
+ input: Record<string, unknown>;
243
+ }
244
+ interface StreamStatusEvent {
245
+ deploymentId: string;
246
+ status?: string;
247
+ endpointUrl?: string;
248
+ estimatedRemainingSeconds?: number;
249
+ error?: string;
250
+ }
251
+ declare function deploymentInfoFromResponse(data: Record<string, unknown>): DeploymentInfo;
252
+ declare function deploymentListResponseFromResponse(data: Record<string, unknown>): DeploymentListResponse;
253
+ declare function deploymentGpuInfoFromResponse(data: Record<string, unknown>): DeploymentGpuInfo;
254
+ declare function deploymentGpuListResponseFromResponse(data: Record<string, unknown>): DeploymentGpuListResponse;
255
+ declare function deploymentLogsResponseFromResponse(data: Record<string, unknown>): DeploymentLogsResponse;
256
+ declare function deploymentCostResponseFromResponse(data: Record<string, unknown>): DeploymentCostResponse;
257
+ declare class Deployments {
258
+ private _client;
259
+ constructor(_client: Client);
260
+ create(options: DeploymentCreateOptions): Promise<DeploymentInfo>;
261
+ list(): Promise<DeploymentListResponse>;
262
+ get(deploymentId: string): Promise<DeploymentInfo>;
263
+ delete(deploymentId: string): Promise<void>;
264
+ run(deploymentId: string, input: Record<string, unknown>): Promise<Record<string, unknown>>;
265
+ getLogs(deploymentId: string): Promise<DeploymentLogsResponse>;
266
+ getCost(deploymentId: string): Promise<DeploymentCostResponse>;
267
+ listGpus(): Promise<DeploymentGpuListResponse>;
268
+ /**
269
+ * Streams deployment status events (SSE).
270
+ * Returns an abort function to stop streaming.
271
+ */
272
+ streamStatus(deploymentId: string, onEvent: (event: StreamStatusEvent) => void, onError?: (error: Error) => void): () => void;
273
+ }
274
+
178
275
  /** Provider key management and balance resources */
179
276
 
180
277
  interface ProviderKeyInfo {
@@ -419,6 +516,7 @@ interface ClientOptions {
419
516
  falKey?: string | null;
420
517
  replicateKey?: string | null;
421
518
  runwayKey?: string | null;
519
+ runpodKey?: string | null;
422
520
  }
423
521
  interface RequestInitWithBody {
424
522
  body?: string;
@@ -437,6 +535,7 @@ declare class Client {
437
535
  readonly requests: Requests;
438
536
  readonly usage: Usage;
439
537
  readonly providers: Providers;
538
+ readonly deployments: Deployments;
440
539
  readonly billing: Billing;
441
540
  private _generate;
442
541
  constructor(options?: ClientOptions);
@@ -512,6 +611,6 @@ declare class VisgateConnectionError extends VisgateError {
512
611
  * Visgate JavaScript/TypeScript SDK — unified client for the Visgate vision AI gateway.
513
612
  */
514
613
 
515
- declare const VERSION = "0.2.2";
614
+ declare const VERSION = "0.3.3";
516
615
 
517
- export { AsyncClient, type AsyncVideoAccepted, AuthenticationError, Billing, type BillingInfo, type CheckoutOptions, Client, type ClientOptions, type DashboardResponse, type FeaturedSection, Generate, type GenerateResult, type ImageResult, Images, type ImagesGenerateOptions, type ModelInfo, type ModelPricing, Models, type ModelsListOptions, type ModelsResponse, type PricingResponse, type ProviderBalanceItem, type ProviderBalancesResponse, ProviderError, type ProviderKeyInfo, type ProviderKeysResponse, type ProviderValidationResult, Providers, RateLimitError, type RequestStatusResult, Requests, Usage, type UsageSummary, VERSION, VIDEO_MODEL_PRESETS, ValidationError, type VideoResult, Videos, type VideosGenerateOptions, VisgateConnectionError, VisgateError, type VisgateErrorDetails, VisgateTimeoutError, billingInfoFromResponse, featuredSectionFromResponse, generateResultFromResponse, imageResultFromResponse, modelInfoFromResponse, modelPricingFromResponse, modelsResponseFromResponse, pricingResponseFromResponse, providerBalanceItemFromResponse, providerBalancesResponseFromResponse, providerKeyInfoFromResponse, providerKeysResponseFromResponse, providerValidationResultFromResponse, requestStatusFromResponse, usageSummaryFromResponse, videoResultFromResponse };
616
+ export { AsyncClient, type AsyncVideoAccepted, AuthenticationError, Billing, type BillingInfo, type CheckoutOptions, Client, type ClientOptions, type DashboardResponse, type DeploymentCostResponse, type DeploymentCreateOptions, type DeploymentGpuInfo, type DeploymentGpuListResponse, type DeploymentInfo, type DeploymentListResponse, type DeploymentLogEntry, type DeploymentLogsResponse, type DeploymentRunRequest, Deployments, type FeaturedSection, Generate, type GenerateResult, type ImageResult, Images, type ImagesGenerateOptions, type ModelInfo, type ModelPricing, Models, type ModelsListOptions, type ModelsResponse, type PricingResponse, type ProviderBalanceItem, type ProviderBalancesResponse, ProviderError, type ProviderKeyInfo, type ProviderKeysResponse, type ProviderValidationResult, Providers, RateLimitError, type RequestStatusResult, Requests, type StreamStatusEvent, Usage, type UsageSummary, VERSION, VIDEO_MODEL_PRESETS, ValidationError, type VideoResult, Videos, type VideosGenerateOptions, VisgateConnectionError, VisgateError, type VisgateErrorDetails, VisgateTimeoutError, billingInfoFromResponse, deploymentCostResponseFromResponse, deploymentGpuInfoFromResponse, deploymentGpuListResponseFromResponse, deploymentInfoFromResponse, deploymentListResponseFromResponse, deploymentLogsResponseFromResponse, featuredSectionFromResponse, generateResultFromResponse, imageResultFromResponse, modelInfoFromResponse, modelPricingFromResponse, modelsResponseFromResponse, pricingResponseFromResponse, providerBalanceItemFromResponse, providerBalancesResponseFromResponse, providerKeyInfoFromResponse, providerKeysResponseFromResponse, providerValidationResultFromResponse, requestStatusFromResponse, usageSummaryFromResponse, videoResultFromResponse };
package/dist/index.js CHANGED
@@ -324,6 +324,183 @@ var Models = class {
324
324
  }
325
325
  };
326
326
 
327
+ // src/resources/deployments.ts
328
+ function deploymentInfoFromResponse(data) {
329
+ return {
330
+ deploymentId: data.deployment_id ?? data.deploymentId ?? "",
331
+ modelId: data.model_id ?? data.modelId,
332
+ status: data.status ?? "unknown",
333
+ endpointUrl: data.endpoint_url ?? data.endpointUrl,
334
+ provider: data.provider ?? "runpod",
335
+ createdAt: data.created_at ?? data.createdAt,
336
+ gpuAllocated: data.gpu_allocated ?? data.gpuAllocated,
337
+ modelVramGb: data.model_vram_gb ?? data.modelVramGb,
338
+ readyAt: data.ready_at ?? data.readyAt,
339
+ error: data.error ?? null
340
+ };
341
+ }
342
+ function deploymentListResponseFromResponse(data) {
343
+ const deployments = data.deployments ?? [];
344
+ return { deployments: deployments.map(deploymentInfoFromResponse) };
345
+ }
346
+ function deploymentGpuInfoFromResponse(data) {
347
+ return {
348
+ id: data.id ?? "",
349
+ displayName: data.display_name ?? data.displayName ?? "",
350
+ memoryGb: data.memory_gb ?? data.memoryGb ?? 0,
351
+ secureCloud: Boolean(data.secure_cloud ?? data.secureCloud),
352
+ communityCloud: Boolean(data.community_cloud ?? data.communityCloud),
353
+ bidPricePerHr: data.bid_price_per_hr ?? data.bidPricePerHr,
354
+ pricePerHr: data.price_per_hr ?? data.pricePerHr
355
+ };
356
+ }
357
+ function deploymentGpuListResponseFromResponse(data) {
358
+ const gpus = data.gpus ?? [];
359
+ return { gpus: gpus.map(deploymentGpuInfoFromResponse) };
360
+ }
361
+ function deploymentLogsResponseFromResponse(data) {
362
+ const rawLogs = data.logs ?? [];
363
+ return {
364
+ deploymentId: data.deployment_id ?? data.deploymentId ?? "",
365
+ logs: rawLogs.map((entry) => ({
366
+ timestamp: entry.timestamp ?? "",
367
+ level: entry.level ?? "INFO",
368
+ message: entry.message ?? ""
369
+ }))
370
+ };
371
+ }
372
+ function deploymentCostResponseFromResponse(data) {
373
+ return {
374
+ deploymentId: data.deployment_id ?? data.deploymentId ?? "",
375
+ status: data.status ?? "unknown",
376
+ gpuAllocated: data.gpu_allocated ?? data.gpuAllocated,
377
+ hoursRunning: data.hours_running ?? data.hoursRunning,
378
+ pricePerHourUsd: data.price_per_hour_usd ?? data.pricePerHourUsd,
379
+ estimatedCostUsd: data.estimated_cost_usd ?? data.estimatedCostUsd,
380
+ note: data.note ?? null
381
+ };
382
+ }
383
+ var Deployments = class {
384
+ constructor(_client) {
385
+ this._client = _client;
386
+ }
387
+ async create(options) {
388
+ const data = await this._client._request("POST", "/deployments", {
389
+ body: JSON.stringify({
390
+ model_name: options.modelName,
391
+ hf_model_id: options.hfModelId,
392
+ gpu_tier: options.gpuTier,
393
+ region: options.region,
394
+ hf_token: options.hfToken,
395
+ runpod_key: options.runpodKey,
396
+ webhook_url: options.webhookUrl,
397
+ cache_scope: options.cacheScope,
398
+ provider: options.provider,
399
+ task: options.task,
400
+ user_s3_url: options.userS3Url,
401
+ user_aws_access_key_id: options.userAwsAccessKeyId,
402
+ user_aws_secret_access_key: options.userAwsSecretAccessKey,
403
+ user_aws_endpoint_url: options.userAwsEndpointUrl
404
+ })
405
+ });
406
+ return deploymentInfoFromResponse(data);
407
+ }
408
+ async list() {
409
+ const data = await this._client._request("GET", "/deployments");
410
+ return deploymentListResponseFromResponse(data);
411
+ }
412
+ async get(deploymentId) {
413
+ const data = await this._client._request(
414
+ "GET",
415
+ `/deployments/${encodeURIComponent(deploymentId)}`
416
+ );
417
+ return deploymentInfoFromResponse(data);
418
+ }
419
+ async delete(deploymentId) {
420
+ await this._client._request("DELETE", `/deployments/${encodeURIComponent(deploymentId)}`);
421
+ }
422
+ async run(deploymentId, input) {
423
+ const data = await this._client._request("POST", `/deployments/${encodeURIComponent(deploymentId)}/run`, {
424
+ body: JSON.stringify({ input })
425
+ });
426
+ return data;
427
+ }
428
+ async getLogs(deploymentId) {
429
+ const data = await this._client._request(
430
+ "GET",
431
+ `/deployments/${encodeURIComponent(deploymentId)}/logs`
432
+ );
433
+ return deploymentLogsResponseFromResponse(data);
434
+ }
435
+ async getCost(deploymentId) {
436
+ const data = await this._client._request(
437
+ "GET",
438
+ `/deployments/${encodeURIComponent(deploymentId)}/cost`
439
+ );
440
+ return deploymentCostResponseFromResponse(data);
441
+ }
442
+ async listGpus() {
443
+ const data = await this._client._request("GET", "/deployments/gpus");
444
+ return deploymentGpuListResponseFromResponse(data);
445
+ }
446
+ /**
447
+ * Streams deployment status events (SSE).
448
+ * Returns an abort function to stop streaming.
449
+ */
450
+ streamStatus(deploymentId, onEvent, onError) {
451
+ const controller = new AbortController();
452
+ const base = this._client.baseUrl.replace(/\/$/, "");
453
+ const url = `${base}/deployments/${encodeURIComponent(deploymentId)}/stream`;
454
+ const headers = {};
455
+ if (this._client.apiKey) headers.Authorization = `Bearer ${this._client.apiKey}`;
456
+ void (async () => {
457
+ try {
458
+ const response = await fetch(url, {
459
+ method: "GET",
460
+ headers,
461
+ signal: controller.signal
462
+ });
463
+ if (!response.ok || !response.body) {
464
+ throw new Error(`SSE stream failed with status ${response.status}`);
465
+ }
466
+ const decoder = new TextDecoder();
467
+ const reader = response.body.getReader();
468
+ let buffer = "";
469
+ while (true) {
470
+ const { value, done } = await reader.read();
471
+ if (done) break;
472
+ buffer += decoder.decode(value, { stream: true });
473
+ const events = buffer.split("\n\n");
474
+ buffer = events.pop() ?? "";
475
+ for (const rawEvent of events) {
476
+ const dataLine = rawEvent.split("\n").find((line) => line.startsWith("data:"));
477
+ if (!dataLine) continue;
478
+ const payload = dataLine.slice(5).trim();
479
+ if (!payload) continue;
480
+ try {
481
+ const parsed = JSON.parse(payload);
482
+ onEvent({
483
+ deploymentId: parsed.deployment_id ?? parsed.deploymentId ?? deploymentId,
484
+ status: parsed.status,
485
+ endpointUrl: parsed.endpoint_url ?? parsed.endpointUrl,
486
+ estimatedRemainingSeconds: parsed.estimated_remaining_seconds,
487
+ error: parsed.error
488
+ });
489
+ } catch {
490
+ }
491
+ }
492
+ }
493
+ } catch (err) {
494
+ if (!controller.signal.aborted) {
495
+ const error = err instanceof Error ? err : new Error(String(err));
496
+ onError?.(error);
497
+ }
498
+ }
499
+ })();
500
+ return () => controller.abort();
501
+ }
502
+ };
503
+
327
504
  // src/resources/providers.ts
328
505
  function providerKeyInfoFromResponse(data) {
329
506
  return {
@@ -591,7 +768,7 @@ var DEFAULT_BASE_URL = "https://visgateai.com/api/v1";
591
768
  var DEFAULT_TIMEOUT = 12e4;
592
769
  var DEFAULT_MAX_RETRIES = 2;
593
770
  var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
594
- var SDK_VERSION = "0.2.2";
771
+ var SDK_VERSION = "0.3.3";
595
772
  function getVersion() {
596
773
  try {
597
774
  if (typeof __VERSION__ !== "undefined") return __VERSION__;
@@ -608,6 +785,7 @@ function buildHeaders(apiKey, options) {
608
785
  if (options.falKey) headers["X-Fal-Key"] = options.falKey;
609
786
  if (options.replicateKey) headers["X-Replicate-Key"] = options.replicateKey;
610
787
  if (options.runwayKey) headers["X-Runway-Key"] = options.runwayKey;
788
+ if (options.runpodKey) headers["X-Runpod-Key"] = options.runpodKey;
611
789
  return headers;
612
790
  }
613
791
  function backoff(attempt) {
@@ -672,7 +850,8 @@ var Client = class {
672
850
  this.headers = buildHeaders(this.apiKey, options.proxyUrl ? {} : {
673
851
  falKey: options.falKey,
674
852
  replicateKey: options.replicateKey,
675
- runwayKey: options.runwayKey
853
+ runwayKey: options.runwayKey,
854
+ runpodKey: options.runpodKey
676
855
  });
677
856
  this.images = new Images(this);
678
857
  this.models = new Models(this);
@@ -680,6 +859,7 @@ var Client = class {
680
859
  this.requests = new Requests(this);
681
860
  this.usage = new Usage(this);
682
861
  this.providers = new Providers(this);
862
+ this.deployments = new Deployments(this);
683
863
  this.billing = new Billing(this);
684
864
  this._generate = new Generate(this);
685
865
  }
@@ -769,8 +949,8 @@ var AsyncClient = class extends Client {
769
949
  };
770
950
 
771
951
  // src/index.ts
772
- var VERSION = "0.2.2";
952
+ var VERSION = "0.3.3";
773
953
 
774
- export { AsyncClient, AuthenticationError, Billing, Client, Generate, Images, Models, ProviderError, Providers, RateLimitError, Requests, Usage, VERSION, VIDEO_MODEL_PRESETS, ValidationError, Videos, VisgateConnectionError, VisgateError, VisgateTimeoutError, billingInfoFromResponse, featuredSectionFromResponse, generateResultFromResponse, imageResultFromResponse, modelInfoFromResponse, modelPricingFromResponse, modelsResponseFromResponse, pricingResponseFromResponse, providerBalanceItemFromResponse, providerBalancesResponseFromResponse, providerKeyInfoFromResponse, providerKeysResponseFromResponse, providerValidationResultFromResponse, requestStatusFromResponse, usageSummaryFromResponse, videoResultFromResponse };
954
+ export { AsyncClient, AuthenticationError, Billing, Client, Deployments, Generate, Images, Models, ProviderError, Providers, RateLimitError, Requests, Usage, VERSION, VIDEO_MODEL_PRESETS, ValidationError, Videos, VisgateConnectionError, VisgateError, VisgateTimeoutError, billingInfoFromResponse, deploymentCostResponseFromResponse, deploymentGpuInfoFromResponse, deploymentGpuListResponseFromResponse, deploymentInfoFromResponse, deploymentListResponseFromResponse, deploymentLogsResponseFromResponse, featuredSectionFromResponse, generateResultFromResponse, imageResultFromResponse, modelInfoFromResponse, modelPricingFromResponse, modelsResponseFromResponse, pricingResponseFromResponse, providerBalanceItemFromResponse, providerBalancesResponseFromResponse, providerKeyInfoFromResponse, providerKeysResponseFromResponse, providerValidationResultFromResponse, requestStatusFromResponse, usageSummaryFromResponse, videoResultFromResponse };
775
955
  //# sourceMappingURL=index.js.map
776
956
  //# sourceMappingURL=index.js.map