@visgate_ai/client 0.3.5 → 0.4.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
@@ -262,6 +262,11 @@ declare class Deployments {
262
262
  get(deploymentId: string): Promise<DeploymentInfo>;
263
263
  delete(deploymentId: string): Promise<void>;
264
264
  run(deploymentId: string, input: Record<string, unknown>): Promise<Record<string, unknown>>;
265
+ /**
266
+ * Get RunPod job status. Use when run() returns status IN_QUEUE or RUNNING
267
+ * so you can poll until COMPLETED and read output (e.g. image URL).
268
+ */
269
+ getStatus(deploymentId: string, jobId: string): Promise<Record<string, unknown>>;
265
270
  getLogs(deploymentId: string): Promise<DeploymentLogsResponse>;
266
271
  getCost(deploymentId: string): Promise<DeploymentCostResponse>;
267
272
  listGpus(): Promise<DeploymentGpuListResponse>;
@@ -293,6 +298,113 @@ declare class HfModels {
293
298
  list(options?: HfModelsListOptions): Promise<HfModelInfo[]>;
294
299
  }
295
300
 
301
+ /** Invitations resource: create, list, cancel, accept, decline */
302
+
303
+ interface Invitation {
304
+ id: string;
305
+ organizationId: string;
306
+ organizationName: string;
307
+ email: string;
308
+ role: string;
309
+ status: string;
310
+ invitedByEmail: string;
311
+ createdAt: string;
312
+ expiresAt: string;
313
+ }
314
+ declare function invitationFromResponse(data: Record<string, unknown>): Invitation;
315
+ declare class Invitations {
316
+ private client;
317
+ constructor(client: Client);
318
+ /** Create an invitation to join an organization. */
319
+ create(orgId: string, email: string, role: "admin" | "member"): Promise<Invitation>;
320
+ /** List pending invitations for an organization. */
321
+ listForOrg(orgId: string): Promise<Invitation[]>;
322
+ /** Cancel a pending invitation. */
323
+ cancel(orgId: string, inviteId: string): Promise<void>;
324
+ /** List pending invitations for the current user. */
325
+ listPending(): Promise<Invitation[]>;
326
+ /** Accept a pending invitation. */
327
+ accept(inviteId: string): Promise<Record<string, unknown>>;
328
+ /** Decline a pending invitation. */
329
+ decline(inviteId: string): Promise<Record<string, unknown>>;
330
+ }
331
+
332
+ /** Members resource: list, role change, remove, leave, ownership transfer */
333
+
334
+ interface Member {
335
+ id: string;
336
+ userId: string;
337
+ email: string;
338
+ displayName: string;
339
+ role: string;
340
+ joinedAt: string;
341
+ }
342
+ declare function memberFromResponse(data: Record<string, unknown>): Member;
343
+ declare class Members {
344
+ private client;
345
+ constructor(client: Client);
346
+ /** List all members of an organization. */
347
+ list(orgId: string): Promise<Member[]>;
348
+ /** Change a member's role. */
349
+ changeRole(orgId: string, userId: string, role: "admin" | "member"): Promise<Record<string, unknown>>;
350
+ /** Remove a member from the organization. */
351
+ remove(orgId: string, userId: string): Promise<void>;
352
+ /** Leave an organization voluntarily. */
353
+ leave(orgId: string): Promise<Record<string, unknown>>;
354
+ /** Transfer ownership to another member. */
355
+ transferOwnership(orgId: string, targetUserId: string): Promise<Record<string, unknown>>;
356
+ }
357
+
358
+ /** Organizations resource: CRUD + permissions */
359
+
360
+ interface Organization {
361
+ id: string;
362
+ name: string;
363
+ slug: string | null;
364
+ tier: string;
365
+ balanceMicro: number;
366
+ balanceDollars: number;
367
+ isPersonal: boolean;
368
+ memberCount: number;
369
+ role: string;
370
+ permissions: string[];
371
+ }
372
+ interface OrganizationSummary {
373
+ id: string;
374
+ name: string;
375
+ slug: string | null;
376
+ role: string;
377
+ isPersonal: boolean;
378
+ }
379
+ interface MemberPermissions {
380
+ permissions: string[];
381
+ }
382
+ declare function organizationFromResponse(data: Record<string, unknown>): Organization;
383
+ declare function organizationSummaryFromResponse(data: Record<string, unknown>): OrganizationSummary;
384
+ declare class Organizations {
385
+ private client;
386
+ constructor(client: Client);
387
+ /** List all organizations the current user belongs to. */
388
+ list(): Promise<OrganizationSummary[]>;
389
+ /** Get organization details by ID. */
390
+ get(orgId: string): Promise<Organization>;
391
+ /** Resolve slug to organization. */
392
+ getBySlug(slug: string): Promise<Record<string, unknown>>;
393
+ /** Create a new non-personal organization. */
394
+ create(name: string): Promise<Organization>;
395
+ /** Update organization name and/or slug. */
396
+ update(orgId: string, updates: {
397
+ name?: string;
398
+ slug?: string;
399
+ }): Promise<Organization>;
400
+ /** Delete a non-personal organization. */
401
+ delete(orgId: string): Promise<void>;
402
+ /** Get configurable member permissions for this organization. */
403
+ getPermissions(orgId: string): Promise<MemberPermissions>;
404
+ /** Update configurable member permissions for this organization. */
405
+ updatePermissions(orgId: string, permissions: string[]): Promise<MemberPermissions>;
406
+ }
407
+
296
408
  /** Provider key management and balance resources */
297
409
 
298
410
  interface ProviderKeyInfo {
@@ -538,6 +650,8 @@ interface ClientOptions {
538
650
  replicateKey?: string | null;
539
651
  runwayKey?: string | null;
540
652
  runpodKey?: string | null;
653
+ /** Organization ID for multi-org context. Sent as X-Org-Id header. */
654
+ orgId?: string | null;
541
655
  }
542
656
  interface RequestInitWithBody {
543
657
  body?: string;
@@ -550,6 +664,7 @@ declare class Client {
550
664
  readonly timeout: number;
551
665
  private readonly headers;
552
666
  private readonly getToken;
667
+ private _orgId;
553
668
  readonly images: Images;
554
669
  readonly models: Models;
555
670
  readonly videos: Videos;
@@ -559,8 +674,20 @@ declare class Client {
559
674
  readonly deployments: Deployments;
560
675
  readonly hfModels: HfModels;
561
676
  readonly billing: Billing;
677
+ readonly organizations: Organizations;
678
+ readonly members: Members;
679
+ readonly invitations: Invitations;
562
680
  private _generate;
563
681
  constructor(options?: ClientOptions);
682
+ /**
683
+ * Set the organization context for subsequent requests.
684
+ * Sent as X-Org-Id header on every request.
685
+ */
686
+ setOrgId(orgId: string | null): void;
687
+ /**
688
+ * Get the current organization context.
689
+ */
690
+ getOrgId(): string | null;
564
691
  /**
565
692
  * Generate an image with a single call.
566
693
  */
@@ -635,4 +762,4 @@ declare class VisgateConnectionError extends VisgateError {
635
762
 
636
763
  declare const VERSION = "0.3.5";
637
764
 
638
- 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 HfModelInfo, HfModels, type HfModelsListOptions, 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 };
765
+ 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 HfModelInfo, HfModels, type HfModelsListOptions, type ImageResult, Images, type ImagesGenerateOptions, type Invitation, Invitations, type Member, type MemberPermissions, Members, type ModelInfo, type ModelPricing, Models, type ModelsListOptions, type ModelsResponse, type Organization, type OrganizationSummary, Organizations, 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, invitationFromResponse, memberFromResponse, modelInfoFromResponse, modelPricingFromResponse, modelsResponseFromResponse, organizationFromResponse, organizationSummaryFromResponse, pricingResponseFromResponse, providerBalanceItemFromResponse, providerBalancesResponseFromResponse, providerKeyInfoFromResponse, providerKeysResponseFromResponse, providerValidationResultFromResponse, requestStatusFromResponse, usageSummaryFromResponse, videoResultFromResponse };
package/dist/index.d.ts CHANGED
@@ -262,6 +262,11 @@ declare class Deployments {
262
262
  get(deploymentId: string): Promise<DeploymentInfo>;
263
263
  delete(deploymentId: string): Promise<void>;
264
264
  run(deploymentId: string, input: Record<string, unknown>): Promise<Record<string, unknown>>;
265
+ /**
266
+ * Get RunPod job status. Use when run() returns status IN_QUEUE or RUNNING
267
+ * so you can poll until COMPLETED and read output (e.g. image URL).
268
+ */
269
+ getStatus(deploymentId: string, jobId: string): Promise<Record<string, unknown>>;
265
270
  getLogs(deploymentId: string): Promise<DeploymentLogsResponse>;
266
271
  getCost(deploymentId: string): Promise<DeploymentCostResponse>;
267
272
  listGpus(): Promise<DeploymentGpuListResponse>;
@@ -293,6 +298,113 @@ declare class HfModels {
293
298
  list(options?: HfModelsListOptions): Promise<HfModelInfo[]>;
294
299
  }
295
300
 
301
+ /** Invitations resource: create, list, cancel, accept, decline */
302
+
303
+ interface Invitation {
304
+ id: string;
305
+ organizationId: string;
306
+ organizationName: string;
307
+ email: string;
308
+ role: string;
309
+ status: string;
310
+ invitedByEmail: string;
311
+ createdAt: string;
312
+ expiresAt: string;
313
+ }
314
+ declare function invitationFromResponse(data: Record<string, unknown>): Invitation;
315
+ declare class Invitations {
316
+ private client;
317
+ constructor(client: Client);
318
+ /** Create an invitation to join an organization. */
319
+ create(orgId: string, email: string, role: "admin" | "member"): Promise<Invitation>;
320
+ /** List pending invitations for an organization. */
321
+ listForOrg(orgId: string): Promise<Invitation[]>;
322
+ /** Cancel a pending invitation. */
323
+ cancel(orgId: string, inviteId: string): Promise<void>;
324
+ /** List pending invitations for the current user. */
325
+ listPending(): Promise<Invitation[]>;
326
+ /** Accept a pending invitation. */
327
+ accept(inviteId: string): Promise<Record<string, unknown>>;
328
+ /** Decline a pending invitation. */
329
+ decline(inviteId: string): Promise<Record<string, unknown>>;
330
+ }
331
+
332
+ /** Members resource: list, role change, remove, leave, ownership transfer */
333
+
334
+ interface Member {
335
+ id: string;
336
+ userId: string;
337
+ email: string;
338
+ displayName: string;
339
+ role: string;
340
+ joinedAt: string;
341
+ }
342
+ declare function memberFromResponse(data: Record<string, unknown>): Member;
343
+ declare class Members {
344
+ private client;
345
+ constructor(client: Client);
346
+ /** List all members of an organization. */
347
+ list(orgId: string): Promise<Member[]>;
348
+ /** Change a member's role. */
349
+ changeRole(orgId: string, userId: string, role: "admin" | "member"): Promise<Record<string, unknown>>;
350
+ /** Remove a member from the organization. */
351
+ remove(orgId: string, userId: string): Promise<void>;
352
+ /** Leave an organization voluntarily. */
353
+ leave(orgId: string): Promise<Record<string, unknown>>;
354
+ /** Transfer ownership to another member. */
355
+ transferOwnership(orgId: string, targetUserId: string): Promise<Record<string, unknown>>;
356
+ }
357
+
358
+ /** Organizations resource: CRUD + permissions */
359
+
360
+ interface Organization {
361
+ id: string;
362
+ name: string;
363
+ slug: string | null;
364
+ tier: string;
365
+ balanceMicro: number;
366
+ balanceDollars: number;
367
+ isPersonal: boolean;
368
+ memberCount: number;
369
+ role: string;
370
+ permissions: string[];
371
+ }
372
+ interface OrganizationSummary {
373
+ id: string;
374
+ name: string;
375
+ slug: string | null;
376
+ role: string;
377
+ isPersonal: boolean;
378
+ }
379
+ interface MemberPermissions {
380
+ permissions: string[];
381
+ }
382
+ declare function organizationFromResponse(data: Record<string, unknown>): Organization;
383
+ declare function organizationSummaryFromResponse(data: Record<string, unknown>): OrganizationSummary;
384
+ declare class Organizations {
385
+ private client;
386
+ constructor(client: Client);
387
+ /** List all organizations the current user belongs to. */
388
+ list(): Promise<OrganizationSummary[]>;
389
+ /** Get organization details by ID. */
390
+ get(orgId: string): Promise<Organization>;
391
+ /** Resolve slug to organization. */
392
+ getBySlug(slug: string): Promise<Record<string, unknown>>;
393
+ /** Create a new non-personal organization. */
394
+ create(name: string): Promise<Organization>;
395
+ /** Update organization name and/or slug. */
396
+ update(orgId: string, updates: {
397
+ name?: string;
398
+ slug?: string;
399
+ }): Promise<Organization>;
400
+ /** Delete a non-personal organization. */
401
+ delete(orgId: string): Promise<void>;
402
+ /** Get configurable member permissions for this organization. */
403
+ getPermissions(orgId: string): Promise<MemberPermissions>;
404
+ /** Update configurable member permissions for this organization. */
405
+ updatePermissions(orgId: string, permissions: string[]): Promise<MemberPermissions>;
406
+ }
407
+
296
408
  /** Provider key management and balance resources */
297
409
 
298
410
  interface ProviderKeyInfo {
@@ -538,6 +650,8 @@ interface ClientOptions {
538
650
  replicateKey?: string | null;
539
651
  runwayKey?: string | null;
540
652
  runpodKey?: string | null;
653
+ /** Organization ID for multi-org context. Sent as X-Org-Id header. */
654
+ orgId?: string | null;
541
655
  }
542
656
  interface RequestInitWithBody {
543
657
  body?: string;
@@ -550,6 +664,7 @@ declare class Client {
550
664
  readonly timeout: number;
551
665
  private readonly headers;
552
666
  private readonly getToken;
667
+ private _orgId;
553
668
  readonly images: Images;
554
669
  readonly models: Models;
555
670
  readonly videos: Videos;
@@ -559,8 +674,20 @@ declare class Client {
559
674
  readonly deployments: Deployments;
560
675
  readonly hfModels: HfModels;
561
676
  readonly billing: Billing;
677
+ readonly organizations: Organizations;
678
+ readonly members: Members;
679
+ readonly invitations: Invitations;
562
680
  private _generate;
563
681
  constructor(options?: ClientOptions);
682
+ /**
683
+ * Set the organization context for subsequent requests.
684
+ * Sent as X-Org-Id header on every request.
685
+ */
686
+ setOrgId(orgId: string | null): void;
687
+ /**
688
+ * Get the current organization context.
689
+ */
690
+ getOrgId(): string | null;
564
691
  /**
565
692
  * Generate an image with a single call.
566
693
  */
@@ -635,4 +762,4 @@ declare class VisgateConnectionError extends VisgateError {
635
762
 
636
763
  declare const VERSION = "0.3.5";
637
764
 
638
- 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 HfModelInfo, HfModels, type HfModelsListOptions, 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 };
765
+ 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 HfModelInfo, HfModels, type HfModelsListOptions, type ImageResult, Images, type ImagesGenerateOptions, type Invitation, Invitations, type Member, type MemberPermissions, Members, type ModelInfo, type ModelPricing, Models, type ModelsListOptions, type ModelsResponse, type Organization, type OrganizationSummary, Organizations, 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, invitationFromResponse, memberFromResponse, modelInfoFromResponse, modelPricingFromResponse, modelsResponseFromResponse, organizationFromResponse, organizationSummaryFromResponse, pricingResponseFromResponse, providerBalanceItemFromResponse, providerBalancesResponseFromResponse, providerKeyInfoFromResponse, providerKeysResponseFromResponse, providerValidationResultFromResponse, requestStatusFromResponse, usageSummaryFromResponse, videoResultFromResponse };
package/dist/index.js CHANGED
@@ -425,6 +425,17 @@ var Deployments = class {
425
425
  });
426
426
  return data;
427
427
  }
428
+ /**
429
+ * Get RunPod job status. Use when run() returns status IN_QUEUE or RUNNING
430
+ * so you can poll until COMPLETED and read output (e.g. image URL).
431
+ */
432
+ async getStatus(deploymentId, jobId) {
433
+ const data = await this._client._request(
434
+ "GET",
435
+ `/deployments/${encodeURIComponent(deploymentId)}/status/${encodeURIComponent(jobId)}`
436
+ );
437
+ return data;
438
+ }
428
439
  async getLogs(deploymentId) {
429
440
  const data = await this._client._request(
430
441
  "GET",
@@ -537,6 +548,171 @@ var HfModels = class {
537
548
  }
538
549
  };
539
550
 
551
+ // src/resources/invitations.ts
552
+ function invitationFromResponse(data) {
553
+ return {
554
+ id: data.id ?? "",
555
+ organizationId: data.organization_id ?? "",
556
+ organizationName: data.organization_name ?? "",
557
+ email: data.email ?? "",
558
+ role: data.role ?? "member",
559
+ status: data.status ?? "pending",
560
+ invitedByEmail: data.invited_by_email ?? "",
561
+ createdAt: data.created_at ?? "",
562
+ expiresAt: data.expires_at ?? ""
563
+ };
564
+ }
565
+ var Invitations = class {
566
+ constructor(client) {
567
+ this.client = client;
568
+ }
569
+ /** Create an invitation to join an organization. */
570
+ async create(orgId, email, role) {
571
+ const data = await this.client._request("POST", `/organizations/${encodeURIComponent(orgId)}/invitations`, {
572
+ body: JSON.stringify({ email, role })
573
+ });
574
+ return invitationFromResponse(data);
575
+ }
576
+ /** List pending invitations for an organization. */
577
+ async listForOrg(orgId) {
578
+ const data = await this.client._request("GET", `/organizations/${encodeURIComponent(orgId)}/invitations`);
579
+ return data.map(invitationFromResponse);
580
+ }
581
+ /** Cancel a pending invitation. */
582
+ async cancel(orgId, inviteId) {
583
+ await this.client._request("DELETE", `/organizations/${encodeURIComponent(orgId)}/invitations/${encodeURIComponent(inviteId)}`);
584
+ }
585
+ /** List pending invitations for the current user. */
586
+ async listPending() {
587
+ const data = await this.client._request("GET", "/invitations/pending");
588
+ return data.map(invitationFromResponse);
589
+ }
590
+ /** Accept a pending invitation. */
591
+ async accept(inviteId) {
592
+ return await this.client._request("POST", `/invitations/${encodeURIComponent(inviteId)}/accept`);
593
+ }
594
+ /** Decline a pending invitation. */
595
+ async decline(inviteId) {
596
+ return await this.client._request("POST", `/invitations/${encodeURIComponent(inviteId)}/decline`);
597
+ }
598
+ };
599
+
600
+ // src/resources/members.ts
601
+ function memberFromResponse(data) {
602
+ return {
603
+ id: data.id ?? "",
604
+ userId: data.user_id ?? "",
605
+ email: data.email ?? "",
606
+ displayName: data.display_name ?? "",
607
+ role: data.role ?? "member",
608
+ joinedAt: data.joined_at ?? ""
609
+ };
610
+ }
611
+ var Members = class {
612
+ constructor(client) {
613
+ this.client = client;
614
+ }
615
+ /** List all members of an organization. */
616
+ async list(orgId) {
617
+ const data = await this.client._request("GET", `/organizations/${encodeURIComponent(orgId)}/members`);
618
+ return data.map(memberFromResponse);
619
+ }
620
+ /** Change a member's role. */
621
+ async changeRole(orgId, userId, role) {
622
+ return await this.client._request("PUT", `/organizations/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}/role`, {
623
+ body: JSON.stringify({ role })
624
+ });
625
+ }
626
+ /** Remove a member from the organization. */
627
+ async remove(orgId, userId) {
628
+ await this.client._request("DELETE", `/organizations/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}`);
629
+ }
630
+ /** Leave an organization voluntarily. */
631
+ async leave(orgId) {
632
+ return await this.client._request("POST", `/organizations/${encodeURIComponent(orgId)}/leave`);
633
+ }
634
+ /** Transfer ownership to another member. */
635
+ async transferOwnership(orgId, targetUserId) {
636
+ return await this.client._request("POST", `/organizations/${encodeURIComponent(orgId)}/transfer-ownership`, {
637
+ body: JSON.stringify({ target_user_id: targetUserId })
638
+ });
639
+ }
640
+ };
641
+
642
+ // src/resources/organizations.ts
643
+ function organizationFromResponse(data) {
644
+ return {
645
+ id: data.id ?? "",
646
+ name: data.name ?? "",
647
+ slug: data.slug ?? null,
648
+ tier: data.tier ?? "free",
649
+ balanceMicro: data.balance_micro ?? 0,
650
+ balanceDollars: data.balance_dollars ?? 0,
651
+ isPersonal: data.is_personal ?? false,
652
+ memberCount: data.member_count ?? 1,
653
+ role: data.role ?? "member",
654
+ permissions: data.permissions ?? []
655
+ };
656
+ }
657
+ function organizationSummaryFromResponse(data) {
658
+ return {
659
+ id: data.id ?? "",
660
+ name: data.name ?? "",
661
+ slug: data.slug ?? null,
662
+ role: data.role ?? "member",
663
+ isPersonal: data.is_personal ?? false
664
+ };
665
+ }
666
+ var Organizations = class {
667
+ constructor(client) {
668
+ this.client = client;
669
+ }
670
+ /** List all organizations the current user belongs to. */
671
+ async list() {
672
+ const data = await this.client._request("GET", "/organizations");
673
+ return data.map(organizationSummaryFromResponse);
674
+ }
675
+ /** Get organization details by ID. */
676
+ async get(orgId) {
677
+ const data = await this.client._request("GET", `/organizations/${encodeURIComponent(orgId)}`);
678
+ return organizationFromResponse(data);
679
+ }
680
+ /** Resolve slug to organization. */
681
+ async getBySlug(slug) {
682
+ return await this.client._request("GET", `/organizations/by-slug/${encodeURIComponent(slug)}`);
683
+ }
684
+ /** Create a new non-personal organization. */
685
+ async create(name) {
686
+ const data = await this.client._request("POST", "/organizations", {
687
+ body: JSON.stringify({ name })
688
+ });
689
+ return organizationFromResponse(data);
690
+ }
691
+ /** Update organization name and/or slug. */
692
+ async update(orgId, updates) {
693
+ const data = await this.client._request("PUT", `/organizations/${encodeURIComponent(orgId)}`, {
694
+ body: JSON.stringify(updates)
695
+ });
696
+ return organizationFromResponse(data);
697
+ }
698
+ /** Delete a non-personal organization. */
699
+ async delete(orgId) {
700
+ await this.client._request("DELETE", `/organizations/${encodeURIComponent(orgId)}`);
701
+ }
702
+ /** Get configurable member permissions for this organization. */
703
+ async getPermissions(orgId) {
704
+ const data = await this.client._request("GET", `/organizations/${encodeURIComponent(orgId)}/permissions`);
705
+ return { permissions: data.permissions ?? [] };
706
+ }
707
+ /** Update configurable member permissions for this organization. */
708
+ async updatePermissions(orgId, permissions) {
709
+ const data = await this.client._request("PUT", `/organizations/${encodeURIComponent(orgId)}/permissions`, {
710
+ body: JSON.stringify({ permissions })
711
+ });
712
+ return { permissions: data.permissions ?? [] };
713
+ }
714
+ };
715
+
540
716
  // src/resources/providers.ts
541
717
  function providerKeyInfoFromResponse(data) {
542
718
  return {
@@ -883,6 +1059,7 @@ var Client = class {
883
1059
  this.baseUrl = (options.proxyUrl ?? options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
884
1060
  this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
885
1061
  this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
1062
+ this._orgId = options.orgId ?? null;
886
1063
  this.headers = buildHeaders(this.apiKey, options.proxyUrl ? {} : {
887
1064
  falKey: options.falKey,
888
1065
  replicateKey: options.replicateKey,
@@ -898,8 +1075,24 @@ var Client = class {
898
1075
  this.deployments = new Deployments(this);
899
1076
  this.hfModels = new HfModels();
900
1077
  this.billing = new Billing(this);
1078
+ this.organizations = new Organizations(this);
1079
+ this.members = new Members(this);
1080
+ this.invitations = new Invitations(this);
901
1081
  this._generate = new Generate(this);
902
1082
  }
1083
+ /**
1084
+ * Set the organization context for subsequent requests.
1085
+ * Sent as X-Org-Id header on every request.
1086
+ */
1087
+ setOrgId(orgId) {
1088
+ this._orgId = orgId;
1089
+ }
1090
+ /**
1091
+ * Get the current organization context.
1092
+ */
1093
+ getOrgId() {
1094
+ return this._orgId;
1095
+ }
903
1096
  /**
904
1097
  * Generate an image with a single call.
905
1098
  */
@@ -923,6 +1116,9 @@ var Client = class {
923
1116
  const token = await Promise.resolve(this.getToken());
924
1117
  headers = { ...headers, Authorization: `Bearer ${token}` };
925
1118
  }
1119
+ if (this._orgId) {
1120
+ headers["X-Org-Id"] = this._orgId;
1121
+ }
926
1122
  const fetchInit = {
927
1123
  method,
928
1124
  ...init,
@@ -988,6 +1184,6 @@ var AsyncClient = class extends Client {
988
1184
  // src/index.ts
989
1185
  var VERSION = "0.3.5";
990
1186
 
991
- export { AsyncClient, AuthenticationError, Billing, Client, Deployments, Generate, HfModels, 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 };
1187
+ export { AsyncClient, AuthenticationError, Billing, Client, Deployments, Generate, HfModels, Images, Invitations, Members, Models, Organizations, ProviderError, Providers, RateLimitError, Requests, Usage, VERSION, VIDEO_MODEL_PRESETS, ValidationError, Videos, VisgateConnectionError, VisgateError, VisgateTimeoutError, billingInfoFromResponse, deploymentCostResponseFromResponse, deploymentGpuInfoFromResponse, deploymentGpuListResponseFromResponse, deploymentInfoFromResponse, deploymentListResponseFromResponse, deploymentLogsResponseFromResponse, featuredSectionFromResponse, generateResultFromResponse, imageResultFromResponse, invitationFromResponse, memberFromResponse, modelInfoFromResponse, modelPricingFromResponse, modelsResponseFromResponse, organizationFromResponse, organizationSummaryFromResponse, pricingResponseFromResponse, providerBalanceItemFromResponse, providerBalancesResponseFromResponse, providerKeyInfoFromResponse, providerKeysResponseFromResponse, providerValidationResultFromResponse, requestStatusFromResponse, usageSummaryFromResponse, videoResultFromResponse };
992
1188
  //# sourceMappingURL=index.js.map
993
1189
  //# sourceMappingURL=index.js.map