@picsart/ai-sdk 6.33.0 → 6.35.0
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/index.d.ts +143 -3
- package/index.js +3604 -3141
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -704,6 +704,13 @@ type ModelInputById = {
|
|
|
704
704
|
duration?: 3 | 5 | 6 | 8 | 10 | 12 | 15;
|
|
705
705
|
imageUrls?: string[];
|
|
706
706
|
};
|
|
707
|
+
"grok-imagine-video-1.5-lite": {
|
|
708
|
+
prompt: string;
|
|
709
|
+
aspectRatio?: "16:9" | "9:16" | "1:1" | "4:3" | "3:4" | "3:2" | "2:3";
|
|
710
|
+
resolution?: "480p" | "720p" | "1080p";
|
|
711
|
+
duration?: 3 | 5 | 6 | 8 | 10 | 12 | 15;
|
|
712
|
+
imageUrls?: string[];
|
|
713
|
+
};
|
|
707
714
|
"grok-tts": {
|
|
708
715
|
language?: string;
|
|
709
716
|
accent?: string;
|
|
@@ -2918,7 +2925,8 @@ interface FilenameHints {
|
|
|
2918
2925
|
/**
|
|
2919
2926
|
* Pick a file extension for a generation. Most to least reliable: the result's
|
|
2920
2927
|
* MIME type, the result URL's path extension, the requested output format, then
|
|
2921
|
-
* the mode default (png / mp4 / mp3).
|
|
2928
|
+
* the mode default (png / mp4 / mp3). An unknown mode resolves to '' — the
|
|
2929
|
+
* filename stays extension-less rather than mislabeled.
|
|
2922
2930
|
*/
|
|
2923
2931
|
declare function resolveExtension(mode: string, hints?: FilenameHints): string;
|
|
2924
2932
|
/**
|
|
@@ -3063,6 +3071,20 @@ declare class ApiError extends Error {
|
|
|
3063
3071
|
constructor(message: string, init: ApiErrorInit);
|
|
3064
3072
|
}
|
|
3065
3073
|
|
|
3074
|
+
/** Catalog query filters — map 1:1 onto `/v1/models-catalog` query params. */
|
|
3075
|
+
interface ModelCatalogFilters {
|
|
3076
|
+
/** Restrict to one or more generation modes (`video`, `image`, …). */
|
|
3077
|
+
mode?: GenerationMode | GenerationMode[];
|
|
3078
|
+
/** Restrict to one or more provider ids. */
|
|
3079
|
+
provider?: string | string[];
|
|
3080
|
+
/** Release tiers to request. Server default: production + general-availability. */
|
|
3081
|
+
release?: ReleaseTag | ReleaseTag[];
|
|
3082
|
+
/** Include models flagged deprecated. */
|
|
3083
|
+
includeDeprecated?: boolean;
|
|
3084
|
+
/** Free-text search across id / name / provider. */
|
|
3085
|
+
search?: string;
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3066
3088
|
/** Worker-reported progress on a generation.progress event. */
|
|
3067
3089
|
type GenerationProgress = WorkflowProgress;
|
|
3068
3090
|
/** A fetch-like function that handles authentication (headers, cookies, etc.). */
|
|
@@ -3086,8 +3108,34 @@ interface AppIdentity {
|
|
|
3086
3108
|
id: string;
|
|
3087
3109
|
type: AppType;
|
|
3088
3110
|
}
|
|
3111
|
+
/**
|
|
3112
|
+
* How the client sources its model catalog and builds generation requests.
|
|
3113
|
+
* - `'static'` (default) — the bundled catalog: per-model workflows and local
|
|
3114
|
+
* payload builders, exactly as before.
|
|
3115
|
+
* - `'dynamic'` — generation routes through the models-hub `v1/models`
|
|
3116
|
+
* workflow (the server builds the vendor payload), and the model catalog is
|
|
3117
|
+
* loaded from the backend via {@link AiClient.initModelCatalog}. Until that
|
|
3118
|
+
* load completes, the sync accessors (`Model()`, `catalog.*`) throw
|
|
3119
|
+
* `ApiError` 409 `catalog_not_loaded`; `generate()`/`submit()` never wait.
|
|
3120
|
+
*
|
|
3121
|
+
* The loaded catalog is process-global (`Model()` and `catalog.*` are
|
|
3122
|
+
* module-level): one catalog source per process, last install wins.
|
|
3123
|
+
*
|
|
3124
|
+
* **One catalog MODE per process, too — do not mix static and dynamic
|
|
3125
|
+
* clients.** Creating a dynamic client flips the process-global catalog:
|
|
3126
|
+
* a static client in the same process then throws `catalog_not_loaded` from
|
|
3127
|
+
* its sync accessors until the load lands, and once the loaded catalog is
|
|
3128
|
+
* installed its generation pipeline would resolve definitions that carry no
|
|
3129
|
+
* payload builders (builders are code and never ride the wire) — producing
|
|
3130
|
+
* invalid vendor payloads. Run static clients in a separate process. Static
|
|
3131
|
+
* mode is the compatibility path and is slated for removal once all
|
|
3132
|
+
* consumers run dynamic.
|
|
3133
|
+
*/
|
|
3134
|
+
type SdkMode = 'static' | 'dynamic';
|
|
3089
3135
|
/** Settings that apply whichever transport serves the client. */
|
|
3090
3136
|
interface ClientConfigBase {
|
|
3137
|
+
/** Catalog/generation mode — see {@link SdkMode}. Default: `'static'`. */
|
|
3138
|
+
mode?: SdkMode;
|
|
3091
3139
|
/** Enable Drive integration — auto-save generations to a Drive folder. */
|
|
3092
3140
|
drive?: DriveConfig;
|
|
3093
3141
|
/**
|
|
@@ -3281,6 +3329,13 @@ interface GenerateOptions {
|
|
|
3281
3329
|
*/
|
|
3282
3330
|
app?: AppIdentity;
|
|
3283
3331
|
}
|
|
3332
|
+
|
|
3333
|
+
/** Options for {@link AiClient.initModelCatalog}. The endpoint is always
|
|
3334
|
+
* `${apiUrl}/gw-v2/v1/models-catalog` — derived from the client's `apiUrl`. */
|
|
3335
|
+
interface InitModelCatalogOptions {
|
|
3336
|
+
/** Restrict what the catalog load requests — mode, provider, release, deprecated, search. */
|
|
3337
|
+
filtersOptions?: ModelCatalogFilters;
|
|
3338
|
+
}
|
|
3284
3339
|
/** Non-text (image/video/audio) model IDs — the media generation surface. */
|
|
3285
3340
|
type MediaModelId = Exclude<TypedModelId, TextModelId | JsonModelId>;
|
|
3286
3341
|
/** AI SDK client with type-safe, model-aware method signatures. */
|
|
@@ -3315,8 +3370,27 @@ interface AiClient {
|
|
|
3315
3370
|
* exceptions.
|
|
3316
3371
|
*/
|
|
3317
3372
|
subscribe(model: MediaModelId, generationId: string, options?: GenerationOptions): AsyncGenerator<GenerationEvent, void, void>;
|
|
3318
|
-
/** Build the vendor-specific payload for a model without submitting. */
|
|
3373
|
+
/** Build the vendor-specific payload for a model without submitting. Static mode only. */
|
|
3319
3374
|
buildPayload<M extends TypedModelId>(model: M, params: ModelInputById[M]): Record<string, unknown>;
|
|
3375
|
+
/**
|
|
3376
|
+
* Dynamic mode only: fetch the model catalog from models-hub and install it
|
|
3377
|
+
* as the active catalog — afterwards `Model()`, `catalog.*` and
|
|
3378
|
+
* `ai.validate()` serve the loaded data. The ONLY trigger for the load
|
|
3379
|
+
* (`createClient` never starts it). Idempotent: concurrent/repeat calls
|
|
3380
|
+
* share one in-flight load; a failed load may be retried. Rejects with
|
|
3381
|
+
* `ApiError` 400 `invalid_mode` on a static client, and 409
|
|
3382
|
+
* `catalog_conflict` when a different url/filters catalog is already loaded
|
|
3383
|
+
* in this process.
|
|
3384
|
+
*/
|
|
3385
|
+
initModelCatalog(options?: InitModelCatalogOptions): Promise<void>;
|
|
3386
|
+
/**
|
|
3387
|
+
* Validate params against the model's descriptors without generating.
|
|
3388
|
+
* Static mode: resolves immediately off the bundled catalog. Dynamic mode:
|
|
3389
|
+
* awaits the catalog load started by {@link initModelCatalog} — rejects
|
|
3390
|
+
* with `ApiError` 409 `catalog_not_loaded` when it was never called.
|
|
3391
|
+
* Unknown models reject with `ApiError` 400 `unknown_model`.
|
|
3392
|
+
*/
|
|
3393
|
+
validate(model: string, params: Record<string, unknown>): Promise<ValidationResult>;
|
|
3320
3394
|
/**
|
|
3321
3395
|
* Direct, low-level access to the Picsart model APIs — run any API by name.
|
|
3322
3396
|
* See {@link ApisClient}.
|
|
@@ -3331,6 +3405,23 @@ interface AiClient {
|
|
|
3331
3405
|
drive: DriveClient | undefined;
|
|
3332
3406
|
}
|
|
3333
3407
|
|
|
3408
|
+
/** Platform options carried on a {@link ModelsCommand} (ModelsGenAIOptions on the backend). */
|
|
3409
|
+
interface ModelsGenAIOptions {
|
|
3410
|
+
safety_checks?: {
|
|
3411
|
+
enabled?: boolean;
|
|
3412
|
+
};
|
|
3413
|
+
drive?: PayloadDriveOptions;
|
|
3414
|
+
inputs_transformation?: {
|
|
3415
|
+
downscale_oversized_images?: boolean;
|
|
3416
|
+
};
|
|
3417
|
+
}
|
|
3418
|
+
/** The `v1/models` request body: which model, the SDK-shaped params, platform options. */
|
|
3419
|
+
interface ModelsCommand {
|
|
3420
|
+
model: string;
|
|
3421
|
+
params: Record<string, unknown>;
|
|
3422
|
+
options?: ModelsGenAIOptions;
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3334
3425
|
/**
|
|
3335
3426
|
* Create an AI SDK client.
|
|
3336
3427
|
*
|
|
@@ -3444,6 +3535,7 @@ declare const Models: {
|
|
|
3444
3535
|
readonly GrokImagineImageQuality: "grok-imagine-image-quality";
|
|
3445
3536
|
readonly GrokImagineVideo: "grok-imagine-video";
|
|
3446
3537
|
readonly GrokImagineVideo15: "grok-imagine-video-1.5";
|
|
3538
|
+
readonly GrokImagineVideo15Lite: "grok-imagine-video-1.5-lite";
|
|
3447
3539
|
readonly GrokTts: "grok-tts";
|
|
3448
3540
|
readonly Hailuo23: "hailuo-2.3";
|
|
3449
3541
|
readonly Hailuo23Fast: "hailuo-2.3-fast";
|
|
@@ -3626,6 +3718,54 @@ declare const Models: {
|
|
|
3626
3718
|
|
|
3627
3719
|
declare function getVoiceById(id: string): VoiceOption | undefined;
|
|
3628
3720
|
|
|
3721
|
+
/** Nested provider block — flattened onto `ModelDefinition.provider*`. */
|
|
3722
|
+
interface CatalogProvider {
|
|
3723
|
+
id: string;
|
|
3724
|
+
name: string;
|
|
3725
|
+
color: string;
|
|
3726
|
+
label: string;
|
|
3727
|
+
}
|
|
3728
|
+
/**
|
|
3729
|
+
* A param as served on the wire: the SDK's flat entry form (descriptor
|
|
3730
|
+
* fields merged with `label` / `required` / `category`), keyed by param
|
|
3731
|
+
* name instead of carrying `key`.
|
|
3732
|
+
*/
|
|
3733
|
+
type CatalogParam = {
|
|
3734
|
+
label?: string;
|
|
3735
|
+
required?: boolean;
|
|
3736
|
+
category?: 'asset' | 'reference';
|
|
3737
|
+
} & ParamDescriptor;
|
|
3738
|
+
interface CatalogModel {
|
|
3739
|
+
id: string;
|
|
3740
|
+
name: string;
|
|
3741
|
+
description?: string;
|
|
3742
|
+
mode: GenerationMode;
|
|
3743
|
+
inputType: InputType;
|
|
3744
|
+
provider: CatalogProvider;
|
|
3745
|
+
badges?: BadgeType[];
|
|
3746
|
+
features?: ModelFeature[];
|
|
3747
|
+
release?: ReleaseTag;
|
|
3748
|
+
addedAt?: string;
|
|
3749
|
+
estimatedTime?: number | Record<string, number>;
|
|
3750
|
+
deprecated?: boolean;
|
|
3751
|
+
/** `include=schema` */
|
|
3752
|
+
params?: Record<string, CatalogParam>;
|
|
3753
|
+
/** `include=constraints` */
|
|
3754
|
+
constraints?: Constraint[];
|
|
3755
|
+
/** `include=routing` */
|
|
3756
|
+
workflow?: string;
|
|
3757
|
+
editWorkflow?: string;
|
|
3758
|
+
modelId?: string;
|
|
3759
|
+
syncExecute?: boolean;
|
|
3760
|
+
}
|
|
3761
|
+
interface CatalogModelsResponse {
|
|
3762
|
+
status: 'success';
|
|
3763
|
+
response: {
|
|
3764
|
+
total: number;
|
|
3765
|
+
models: CatalogModel[];
|
|
3766
|
+
};
|
|
3767
|
+
}
|
|
3768
|
+
|
|
3629
3769
|
/**
|
|
3630
3770
|
* Pricing internals — owns the ModelPricingClient, the per-model cache, and
|
|
3631
3771
|
* the credit-range lookup. The Model accessor delegates to the helpers below
|
|
@@ -3758,4 +3898,4 @@ declare const getModel: (id: string) => ModelDefinition | undefined;
|
|
|
3758
3898
|
*/
|
|
3759
3899
|
declare const findModel: (ref: string) => ModelDefinition | undefined;
|
|
3760
3900
|
|
|
3761
|
-
export { ALL_MODELS, type AiClient, ApiError, type ApiErrorCode, type ApiErrorInit, type ApiResponse, type ApiRunOptions, type ApiSchemas, type ApisClient, type AppIdentity, type AppType, type AuthenticatedFetch, type AvatarOption, type BooleanDescriptor, type BooleanEntry, type CatalogDescriptor, type CatalogEntry, type CatalogItem, type CatalogPage, type CatalogPageOptions, type CatalogPreview, type CatalogQuery, type CatalogResult, type CatalogSource, type CatalogsClient, type CatalogsOptions, type ClientConfig, type CreditRange, type CreditRangeContext, type CreditTier, type CreditUsage, DEFAULT_VISIBLE_RELEASES, type DeepLinkResult, type DriveAttributes, type DriveClient, type DriveConfig, type DriveDraftInfo, type DriveFile, type DriveFileDetails, type DriveFolder, type DriveMediaItem, type DriveSaveResult, type EntryMeta, type EnumDescriptor, type EnumEntry, type EnumOption, type FileDescriptor, type FileEntry, type FlatParamEntry, type GenerateOptions, type GenerateResult, type GenerateResultItem, type GenerateResultItemMetadata, type GenerateTextResult, type GenerationContext, type GenerationEvent, GenerationEventType, type GenerationFile, type GenerationMode, type GenerationOptions, type GenerationProgress, type GenerationProvenance, type JsonModelId, type ListOptions, type MediaModelId, type MediaTypeFilter, Model, type ModelDefinition, type ModelDescriptor, type ModelFilter, type ModelInput, type ModelInputById, type ModelMeta, type ModelParams, type ModelParamsAccessor, Models, type ObjectDescriptor, type ObjectEntry, type OptionsResult, type ParamDescriptor, type ParamEntry, type ParamOption, type PayloadDriveFolderOptions, type PayloadDriveOptions, type PayloadInputsTransformationOptions, type PricingOptions, type ProviderInfo, type RangeDescriptor, type RangeEntry, type ReleaseTag, type RunResponse, type SaveParams, type SdkPayload, type SdkTransport, type SeedanceDraftTask, type TextDescriptor, type TextEntry, type TextModelId, type TextModelInputById, type ToolUsage, type TransportPollOptions, type TransportResult, type TypedModelId, type UnknownDescriptor, type UnknownEntry, type UserReaction, type ValidationResult, type VoiceOption, type WorkflowJobHandle, type WorkflowSubmitRequest, buildFilename, buildGenerationAttributes, catalog, createClient, decodeDeepLinkPayload, encodeDeepLinkPayload, expectedOutputFormat, findModel, getModel, getModelsByMode, getVoiceById, inferResourceType, isVisibleForReleases, parseGeneration, releaseOf, resolveExtension, toAvatarOption, toVoiceOption };
|
|
3901
|
+
export { ALL_MODELS, type AiClient, ApiError, type ApiErrorCode, type ApiErrorInit, type ApiResponse, type ApiRunOptions, type ApiSchemas, type ApisClient, type AppIdentity, type AppType, type AuthenticatedFetch, type AvatarOption, type BooleanDescriptor, type BooleanEntry, type CatalogDescriptor, type CatalogEntry, type CatalogItem, type CatalogModel, type CatalogModelsResponse, type CatalogPage, type CatalogPageOptions, type CatalogParam, type CatalogPreview, type CatalogProvider, type CatalogQuery, type CatalogResult, type CatalogSource, type CatalogsClient, type CatalogsOptions, type ClientConfig, type CreditRange, type CreditRangeContext, type CreditTier, type CreditUsage, DEFAULT_VISIBLE_RELEASES, type DeepLinkResult, type DriveAttributes, type DriveClient, type DriveConfig, type DriveDraftInfo, type DriveFile, type DriveFileDetails, type DriveFolder, type DriveMediaItem, type DriveSaveResult, type EntryMeta, type EnumDescriptor, type EnumEntry, type EnumOption, type FileDescriptor, type FileEntry, type FlatParamEntry, type GenerateOptions, type GenerateResult, type GenerateResultItem, type GenerateResultItemMetadata, type GenerateTextResult, type GenerationContext, type GenerationEvent, GenerationEventType, type GenerationFile, type GenerationMode, type GenerationOptions, type GenerationProgress, type GenerationProvenance, type InitModelCatalogOptions, type JsonModelId, type ListOptions, type MediaModelId, type MediaTypeFilter, Model, type ModelCatalogFilters, type ModelDefinition, type ModelDescriptor, type ModelFilter, type ModelInput, type ModelInputById, type ModelMeta, type ModelParams, type ModelParamsAccessor, Models, type ModelsCommand, type ModelsGenAIOptions, type ObjectDescriptor, type ObjectEntry, type OptionsResult, type ParamDescriptor, type ParamEntry, type ParamOption, type PayloadDriveFolderOptions, type PayloadDriveOptions, type PayloadInputsTransformationOptions, type PricingOptions, type ProviderInfo, type RangeDescriptor, type RangeEntry, type ReleaseTag, type RunResponse, type SaveParams, type SdkMode, type SdkPayload, type SdkTransport, type SeedanceDraftTask, type TextDescriptor, type TextEntry, type TextModelId, type TextModelInputById, type ToolUsage, type TransportPollOptions, type TransportResult, type TypedModelId, type UnknownDescriptor, type UnknownEntry, type UserReaction, type ValidationResult, type VoiceOption, type WorkflowJobHandle, type WorkflowSubmitRequest, buildFilename, buildGenerationAttributes, catalog, createClient, decodeDeepLinkPayload, encodeDeepLinkPayload, expectedOutputFormat, findModel, getModel, getModelsByMode, getVoiceById, inferResourceType, isVisibleForReleases, parseGeneration, releaseOf, resolveExtension, toAvatarOption, toVoiceOption };
|