@picsart/ai-sdk 6.25.0 → 6.29.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.
Files changed (4) hide show
  1. package/README.md +34 -0
  2. package/index.d.ts +73 -19
  3. package/index.js +168 -43
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -235,6 +235,40 @@ catalog.find({ output: 'text' })
235
235
  image/video model throws, and `generate()` throws on a text model — use the matching
236
236
  method for each.
237
237
 
238
+ ## Generic Execution — ai.run()
239
+
240
+ `run()` executes any model by id and answers the task result generically — the
241
+ model-id counterpart of `ai.apis.run()` (which is keyed by API name). It works
242
+ on every model and runs one uniform path: paramConfig validation, vendor payload
243
+ build, workflow execution (sync or async), and the model's `outputSchema` when
244
+ one is declared. The result comes back as-is in `{ result, status, usage, id }` —
245
+ no media-URL or text extraction, no Drive save. Use `generate()`/`generateText()`
246
+ when you want the parsed media/text surfaces; use `run()` when you want the raw
247
+ task result — and for `mode: 'json'` models, `run()` is the only surface:
248
+ structured-output models (judges, evaluators, classifiers) are rejected by
249
+ `generate()`, `generateText()`, and the async lifecycle.
250
+
251
+ The first json model is `typesafe-evaluate` (`Models.TypesafeEvaluate`) — LLM-judge
252
+ evaluation of any content against named questions. Type the result via the `R`
253
+ generic, same as `ai.apis.run()`:
254
+
255
+ ```typescript
256
+ interface EvaluateResult { model: string; answers: Record<string, unknown>; usage: unknown }
257
+
258
+ const { result } = await ai.run<EvaluateResult>(Models.TypesafeEvaluate, {
259
+ state: 'The weather is lovely and everyone is having a great time.',
260
+ questions: {
261
+ is_safe: { type: 'noul', instructions: 'Is this content safe for all audiences?' },
262
+ tone: { type: 'choice', instructions: 'Pick the tone.', options: ['positive', 'neutral', 'negative'] },
263
+ },
264
+ })
265
+ // result: { model: 'jev-1.13.0', answers: { is_safe: …, tone: … }, usage: { input_tokens, output_tokens } }
266
+ ```
267
+
268
+ Question ids are caller-chosen; each question is `noul` (yes/no), `choice`, or
269
+ `score`, with type-specific extras (`options`, bounds — see the
270
+ [TypeSafe docs](https://docs.typesafe.ai/api)) passed through as-is.
271
+
238
272
  ## Voice, Avatar & Template Catalogs
239
273
 
240
274
  Models with catalog-backed params (voices, avatars, effect / caption templates) serve their option lists
package/index.d.ts CHANGED
@@ -506,6 +506,15 @@ type ModelInputById = {
506
506
  voiceName: string;
507
507
  }>;
508
508
  };
509
+ "gemini-nano-banana-2.1": {
510
+ prompt: string;
511
+ aspectRatio?: "1:1" | "16:9" | "9:16" | "3:4" | "4:3" | "2:3" | "21:9" | "auto";
512
+ resolution?: "1K" | "2K" | "4K";
513
+ count?: 1 | 2 | 4 | 6 | 8 | 10;
514
+ seed?: number;
515
+ thinkingLevel?: "minimal" | "medium" | "high";
516
+ imageUrls?: string[];
517
+ };
509
518
  "gemini-omni-1.1-flash-preview": {
510
519
  prompt: string;
511
520
  aspectRatio?: "16:9" | "9:16";
@@ -1894,14 +1903,6 @@ type ModelInputById = {
1894
1903
  imageUrls?: string[];
1895
1904
  negativePrompt?: string;
1896
1905
  };
1897
- "spicy-mayo": {
1898
- prompt: string;
1899
- aspectRatio?: "1:1" | "16:9" | "9:16" | "3:4" | "4:3" | "2:3" | "21:9" | "auto";
1900
- count?: 1 | 2 | 4 | 6 | 8 | 10;
1901
- seed?: number;
1902
- thinkingLevel?: "minimal" | "medium" | "high";
1903
- imageUrls?: string[];
1904
- };
1905
1906
  "topaz-upscale-image": {
1906
1907
  imageUrls: [string, ...string[]];
1907
1908
  model?: "Standard V2" | "Standard MAX" | "Low Resolution V2" | "High Fidelity V2" | "CGI" | "Text Refine" | "Redefine" | "Recovery" | "Recovery V2" | "Wonder" | "Wonder 3";
@@ -1910,6 +1911,13 @@ type ModelInputById = {
1910
1911
  videoUrl: string;
1911
1912
  model?: "Proteus" | "Artemis HQ" | "Artemis MQ" | "Artemis LQ" | "Nyx" | "Nyx Fast" | "Nyx XL" | "Nyx HF" | "Gaia HQ" | "Gaia CG" | "Gaia 2" | "Starlight Precise 2.5" | "Starlight HQ" | "Starlight Mini" | "Starlight Sharp" | "Starlight Fast 2";
1912
1913
  };
1914
+ "typesafe-evaluate": {
1915
+ state: string;
1916
+ questions: Record<string, {
1917
+ type: "noul" | "choice" | "score";
1918
+ instructions: unknown;
1919
+ } & Record<string, unknown>>;
1920
+ };
1913
1921
  "veed-fabric-v1": {
1914
1922
  prompt?: string;
1915
1923
  resolution?: "480p" | "720p";
@@ -2049,6 +2057,8 @@ type ModelInput<M extends TypedModelId> = ModelInputById[M];
2049
2057
  /** IDs of text-generation (LLM) models — narrows generateText(). */
2050
2058
  type TextModelId = "claude-fable-5" | "claude-fable-5-1" | "claude-haiku-4-5" | "claude-opus-4-8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-5" | "eleven-speech-to-text" | "gemini-2.5-flash" | "gemini-3-pro" | "gemini-3.5-flash-lite" | "gemini-3.6-flash" | "gemini-3.7-flash" | "gemini-3.8-flash" | "gpt-4.1-mini" | "gpt-4.1-nano" | "gpt-4o" | "gpt-4o-mini" | "gpt-5" | "gpt-5-mini" | "gpt-5.1" | "gpt-5.2" | "gpt-5.5" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "gpt-6-astra" | "gpt-6-luna" | "gpt-6-sol";
2051
2059
  type TextModelInputById = Pick<ModelInputById, TextModelId>;
2060
+ /** IDs of structured-output (json-mode) models — narrows run()'s result type. */
2061
+ type JsonModelId = "typesafe-evaluate";
2052
2062
 
2053
2063
  interface ParamSchema {
2054
2064
  type: 'string' | 'number' | 'boolean' | 'file';
@@ -2260,18 +2270,34 @@ interface FileDescriptor {
2260
2270
  */
2261
2271
  maxBytes?: number;
2262
2272
  }
2273
+ /** Any value — no validation, generates as `unknown`. Only meaningful as an
2274
+ * ObjectDescriptor's `additionalProperties` (or a nested field): it marks a
2275
+ * pass-through slot whose shape the vendor owns. */
2276
+ interface UnknownDescriptor {
2277
+ kind: 'unknown';
2278
+ }
2263
2279
  interface ObjectDescriptor {
2264
2280
  kind: 'object';
2265
- /** Nested fields use the flat EntryMeta + Descriptor merge — same shape as
2281
+ /** Declared fields — flat EntryMeta + Descriptor merge, same shape as
2266
2282
  * EnumEntry / RangeEntry / etc. Authors can mark a nested field optional
2267
2283
  * by setting `required: false`. Default is required. */
2268
- fields: Record<string, EntryMeta & ParamDescriptor>;
2284
+ fields?: Record<string, EntryMeta & ParamDescriptor>;
2285
+ /**
2286
+ * JSON-Schema-style `additionalProperties`: keys beyond `fields` are
2287
+ * allowed, each value validated against this descriptor. With no `fields`
2288
+ * the object is an open-keyed dictionary (generates `Record<string, V>` —
2289
+ * e.g. question id → question object); alongside `fields` it admits
2290
+ * vendor-defined extras (generates `{ …fields } & Record<string, V>`).
2291
+ * Use `{ kind: 'unknown' }` to pass extras through unvalidated.
2292
+ * Omitted → closed shape: exactly `fields`.
2293
+ */
2294
+ additionalProperties?: ParamDescriptor;
2269
2295
  array?: {
2270
2296
  min?: number;
2271
2297
  max?: number;
2272
2298
  };
2273
2299
  }
2274
- type ParamDescriptor = EnumDescriptor<string> | EnumDescriptor<number> | CatalogDescriptor | RangeDescriptor | BooleanDescriptor | TextDescriptor | FileDescriptor | ObjectDescriptor;
2300
+ type ParamDescriptor = EnumDescriptor<string> | EnumDescriptor<number> | CatalogDescriptor | RangeDescriptor | BooleanDescriptor | TextDescriptor | FileDescriptor | ObjectDescriptor | UnknownDescriptor;
2275
2301
  interface ParamEntry {
2276
2302
  label?: string;
2277
2303
  required?: boolean;
@@ -2306,6 +2332,7 @@ type BooleanEntry = EntryMeta & BooleanDescriptor;
2306
2332
  type TextEntry = EntryMeta & TextDescriptor;
2307
2333
  type FileEntry = EntryMeta & FileDescriptor;
2308
2334
  type ObjectEntry = EntryMeta & ObjectDescriptor;
2335
+ type UnknownEntry = EntryMeta & UnknownDescriptor;
2309
2336
  /** Flat param entry with key — returned by ModelAccessor.params(). */
2310
2337
  type FlatParamEntry = EntryMeta & ParamDescriptor & {
2311
2338
  key: string;
@@ -2433,11 +2460,13 @@ interface ModelFilter {
2433
2460
  release?: ReleaseTag[];
2434
2461
  }
2435
2462
 
2436
- type AppProvider = 'picsart' | 'google' | 'kling' | 'grok' | 'openai' | 'flux' | 'ideogram' | 'elevenlabs' | 'minimax' | 'wan' | 'seedance' | 'ltx' | 'seedream' | 'seedaudio' | 'hunyuan' | 'pika' | 'runway' | 'luma' | 'ovi' | 'creatify' | 'veed' | 'bytedance' | 'qwen' | 'reve' | 'recraft' | 'videography' | 'topaz' | 'heygen' | 'happyhorse' | 'pixverse' | 'anthropic' | 'async' | 'captionsai' | 'meta';
2463
+ type AppProvider = 'picsart' | 'google' | 'kling' | 'grok' | 'openai' | 'flux' | 'ideogram' | 'elevenlabs' | 'minimax' | 'wan' | 'seedance' | 'ltx' | 'seedream' | 'seedaudio' | 'hunyuan' | 'pika' | 'runway' | 'luma' | 'ovi' | 'creatify' | 'veed' | 'bytedance' | 'qwen' | 'reve' | 'recraft' | 'videography' | 'topaz' | 'heygen' | 'happyhorse' | 'pixverse' | 'anthropic' | 'async' | 'captionsai' | 'meta' | 'typesafe';
2437
2464
  /** Provider used by model definitions. */
2438
2465
  type Provider = AppProvider;
2439
- /** App generation modes. */
2440
- type GenerationMode = 'video' | 'image' | 'audio' | 'text';
2466
+ /** App generation modes. `json` marks structured-output models (judges,
2467
+ * evaluators, classifiers) — no media URL, no extractable text; their parsed
2468
+ * result is returned as-is by `ai.run()`. */
2469
+ type GenerationMode = 'video' | 'image' | 'audio' | 'text' | 'json';
2441
2470
  /** App input types. */
2442
2471
  type InputType = 't2v' | 'i2v' | 'v2v' | 'a2v' | 't2i' | 'i2i' | 't2a' | 'v2a' | 'tts' | 'sts' | 'sfx' | 'music' | 't2t' | 'i2t' | 'v2t' | 'a2t';
2443
2472
  interface ModelFeature {
@@ -3121,6 +3150,20 @@ interface GenerateResult {
3121
3150
  /** Present when Drive is enabled and the file was saved. */
3122
3151
  drive?: DriveSaveResult;
3123
3152
  }
3153
+ /**
3154
+ * Response of {@link AiClient.run} — the same shape `ai.apis.run()` answers
3155
+ * ({ result, status, usage, id }), in the SDK's own vocabulary.
3156
+ */
3157
+ interface RunResponse<R = unknown> {
3158
+ /** The task result as-is, validated by the model's `outputSchema` when declared. */
3159
+ result: R;
3160
+ /** Always `COMPLETED` — failures throw {@link ApiError} instead. */
3161
+ status: 'COMPLETED';
3162
+ /** Credit usage reported by the platform — same structure as the pluggable APIs' GenAITaskResponse. */
3163
+ usage?: CreditUsage;
3164
+ /** The generation/job id — absent for syncExecute models (nothing to poll). */
3165
+ id?: string;
3166
+ }
3124
3167
  /** Result of a text-generation (LLM) model. */
3125
3168
  interface GenerateTextResult {
3126
3169
  /** Generated text. */
@@ -3189,13 +3232,13 @@ interface GenerateOptions {
3189
3232
  signal?: AbortSignal;
3190
3233
  /**
3191
3234
  * Poll interval for the async status loop, in ms. Overrides the model's
3192
- * `pollOptions` and the mode default (video 2s; image/audio/text 1s).
3235
+ * `pollOptions` and the mode default (video 2s; image/audio/text/json 1s).
3193
3236
  */
3194
3237
  intervalMs?: number;
3195
3238
  /**
3196
3239
  * Max poll attempts before the call throws a timeout. Overrides the model's
3197
3240
  * `pollOptions` and the mode default (video 1800 ≈ 1 hour;
3198
- * image/audio/text 1200 ≈ 20 min).
3241
+ * image/audio/text/json 1200 ≈ 20 min).
3199
3242
  */
3200
3243
  maxAttempts?: number;
3201
3244
  /** Save to a specific subfolder instead of the root (legacy — used by SDK DriveConfig). */
@@ -3213,9 +3256,19 @@ interface GenerateOptions {
3213
3256
  app?: AppIdentity;
3214
3257
  }
3215
3258
  /** Non-text (image/video/audio) model IDs — the media generation surface. */
3216
- type MediaModelId = Exclude<TypedModelId, TextModelId>;
3259
+ type MediaModelId = Exclude<TypedModelId, TextModelId | JsonModelId>;
3217
3260
  /** AI SDK client with type-safe, model-aware method signatures. */
3218
3261
  interface AiClient {
3262
+ /**
3263
+ * Run any model by id and get the task result back, generically — the
3264
+ * model-id counterpart of {@link ApisClient.run}. Works on every model:
3265
+ * builds and validates the payload from paramConfig, executes the workflow,
3266
+ * applies the model's `outputSchema` when declared, and answers the task
3267
+ * result as-is (no media-URL/text extraction, no Drive save). The only
3268
+ * generation surface for json-mode (structured-output) models. Type the
3269
+ * result via `R` (mirrors `ai.apis.run()`): `ai.run<MyResult>(id, params)`.
3270
+ */
3271
+ run<R = unknown, M extends TypedModelId = TypedModelId>(model: M, params: ModelInputById[M], options?: GenerateOptions): Promise<RunResponse<R>>;
3219
3272
  /** Generate content using a media model. Text/LLM models use generateText(). */
3220
3273
  generate<M extends MediaModelId>(model: M, params: ModelInputById[M], options?: GenerateOptions): Promise<GenerateResult>;
3221
3274
  /** Generate text using an LLM model. Returns the generated text plus the raw response. */
@@ -3333,6 +3386,7 @@ declare const Models: {
3333
3386
  readonly Gemini38Flash: "gemini-3.8-flash";
3334
3387
  readonly Gemini38FlashLiteTts: "gemini-3.8-flash-lite-tts";
3335
3388
  readonly Gemini38FlashTts: "gemini-3.8-flash-tts";
3389
+ readonly GeminiNanoBanana21: "gemini-nano-banana-2.1";
3336
3390
  readonly GeminiOmni11FlashPreview: "gemini-omni-1.1-flash-preview";
3337
3391
  readonly GeminiOmniFlashPreview: "gemini-omni-flash-preview";
3338
3392
  readonly Gpt41Mini: "gpt-4.1-mini";
@@ -3515,9 +3569,9 @@ declare const Models: {
3515
3569
  readonly Seedream50Flash: "seedream-5.0-flash";
3516
3570
  readonly Seedream50Lite: "seedream-5.0-lite";
3517
3571
  readonly Seedream50Pro: "seedream-5.0-pro";
3518
- readonly SpicyMayo: "spicy-mayo";
3519
3572
  readonly TopazUpscaleImage: "topaz-upscale-image";
3520
3573
  readonly TopazUpscaleVideo: "topaz-upscale-video";
3574
+ readonly TypesafeEvaluate: "typesafe-evaluate";
3521
3575
  readonly VeedFabricV1: "veed-fabric-v1";
3522
3576
  readonly VeedFabricV1Fast: "veed-fabric-v1-fast";
3523
3577
  readonly Veo31: "veo-3.1";
@@ -3674,4 +3728,4 @@ declare const getModel: (id: string) => ModelDefinition | undefined;
3674
3728
  */
3675
3729
  declare const findModel: (ref: string) => ModelDefinition | undefined;
3676
3730
 
3677
- 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 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 SaveParams, type SdkPayload, type SdkTransport, type SeedanceDraftTask, type TextDescriptor, type TextEntry, type TextModelId, type TextModelInputById, type ToolUsage, type TransportPollOptions, type TransportResult, type TypedModelId, 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 };
3731
+ 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 };
package/index.js CHANGED
@@ -566,12 +566,22 @@ function validateDescriptor(key, d, val, required) {
566
566
  `"${key}" allows at most ${d.array.max} items`
567
567
  );
568
568
  }
569
+ const declared = d.fields ?? {};
569
570
  for (const item of items) {
570
571
  if (item == null || typeof item !== "object" || Array.isArray(item)) {
571
- throw new Error(`"${key}" items must be objects`);
572
+ throw new Error(d.array ? `"${key}" items must be objects` : `"${key}" must be an object`);
572
573
  }
573
- for (const [fk, fd] of Object.entries(d.fields)) {
574
- validateDescriptor(`${key}.${fk}`, fd, item[fk]);
574
+ if (required && !d.array && d.additionalProperties && Object.keys(declared).length === 0 && Object.keys(item).length === 0) {
575
+ throw new Error(`"${key}" is required`);
576
+ }
577
+ for (const [fk, fd] of Object.entries(declared)) {
578
+ validateDescriptor(`${key}.${fk}`, fd, item[fk], fd.required);
579
+ }
580
+ if (d.additionalProperties) {
581
+ for (const [ek, ev] of Object.entries(item)) {
582
+ if (ek in declared) continue;
583
+ validateDescriptor(`${key}.${ek}`, d.additionalProperties, ev, true);
584
+ }
575
585
  }
576
586
  }
577
587
  break;
@@ -784,7 +794,8 @@ var providers = {
784
794
  anthropic: { color: "#D97757", label: "CL", name: "Anthropic" },
785
795
  async: { color: "#5E5CE6", label: "AA", name: "Async AI" },
786
796
  captionsai: { color: "#1D1F20", label: "MR", name: "Mirage" },
787
- meta: { color: "#0081FB", label: "MT", name: "Meta" }
797
+ meta: { color: "#0081FB", label: "MT", name: "Meta" },
798
+ typesafe: { color: "#3E6B8F", label: "TS", name: "TypeSafe" }
788
799
  };
789
800
 
790
801
  // src/core/descriptors/presets.ts
@@ -1162,7 +1173,7 @@ var passthroughPayload = (paramConfig) => (ctx) => {
1162
1173
  return payload;
1163
1174
  };
1164
1175
  function defineModels(provider, configs) {
1165
- const MODELS38 = [];
1176
+ const MODELS39 = [];
1166
1177
  for (const c of configs) {
1167
1178
  const prov = c.provider ?? provider;
1168
1179
  const resolvedPayload = c.buildPayload ?? passthroughPayload(c.paramConfig);
@@ -1198,19 +1209,19 @@ function defineModels(provider, configs) {
1198
1209
  if (c.constraints !== void 0) model.constraints = c.constraints;
1199
1210
  const contract = createModelContract(model);
1200
1211
  model.outputSchema = c.outputSchema ?? contract.output;
1201
- MODELS38.push(model);
1212
+ MODELS39.push(model);
1202
1213
  }
1203
- return { MODELS: MODELS38 };
1214
+ return { MODELS: MODELS39 };
1204
1215
  }
1205
- function registerPayloads(MODELS38, payloads) {
1216
+ function registerPayloads(MODELS39, payloads) {
1206
1217
  for (const [id, builder] of Object.entries(payloads)) {
1207
- const model = MODELS38.find((m) => m.id === id);
1218
+ const model = MODELS39.find((m) => m.id === id);
1208
1219
  if (model) model.buildPayload = builder;
1209
1220
  }
1210
1221
  }
1211
- function registerEditPayloads(MODELS38, payloads) {
1222
+ function registerEditPayloads(MODELS39, payloads) {
1212
1223
  for (const [id, builder] of Object.entries(payloads)) {
1213
- const model = MODELS38.find((m) => m.id === id);
1224
+ const model = MODELS39.find((m) => m.id === id);
1214
1225
  if (model) model.buildEditPayload = builder;
1215
1226
  }
1216
1227
  }
@@ -4176,6 +4187,10 @@ var SEEDANCE_25_VIDEO_BOUNDS = {
4176
4187
  maxDurationSec: SEEDANCE_25_MAX_MEDIA_SEC,
4177
4188
  maxFrameRate: SEEDANCE_MAX_FRAME_RATE
4178
4189
  };
4190
+ var SEEDANCE_25_EDIT_SOURCE_BOUNDS = {
4191
+ ...SEEDANCE_25_VIDEO_BOUNDS,
4192
+ minDurationSec: 4
4193
+ };
4179
4194
  var SEEDANCE_20_VIDEO_BOUNDS = {
4180
4195
  minAspectRatio: SEEDANCE_MIN_ASPECT_RATIO,
4181
4196
  maxAspectRatio: SEEDANCE_MAX_ASPECT_RATIO,
@@ -4658,7 +4673,7 @@ var { MODELS: MODELS13 } = defineModels("bytedance", [
4658
4673
  ...seedance25DraftParam,
4659
4674
  // Every limit rides in `bounds`; the positional maxDuration / maxShortSide
4660
4675
  // / maxBytes args predate it and are skipped rather than duplicated.
4661
- ...params.videoInput("Source Video", "reference", true, void 0, void 0, void 0, SEEDANCE_25_VIDEO_BOUNDS),
4676
+ ...params.videoInput("Source Video", "reference", true, void 0, void 0, void 0, SEEDANCE_25_EDIT_SOURCE_BOUNDS),
4662
4677
  ...params.imageInput(30, "Reference Images", false, "reference", SEEDANCE_IMAGE_BOUNDS)
4663
4678
  }
4664
4679
  },
@@ -4690,7 +4705,7 @@ var { MODELS: MODELS13 } = defineModels("bytedance", [
4690
4705
  ...seedance25DraftParam,
4691
4706
  // Every limit rides in `bounds`; the positional maxDuration / maxShortSide
4692
4707
  // / maxBytes args predate it and are skipped rather than duplicated.
4693
- ...params.videoInput("Source Video", "reference", true, void 0, void 0, void 0, SEEDANCE_25_VIDEO_BOUNDS),
4708
+ ...params.videoInput("Source Video", "reference", true, void 0, void 0, void 0, SEEDANCE_25_EDIT_SOURCE_BOUNDS),
4694
4709
  ...params.imageInput(30, "Reference Images", false, "reference", SEEDANCE_IMAGE_BOUNDS)
4695
4710
  }
4696
4711
  },
@@ -6474,14 +6489,14 @@ var buildGemini31FlashLiteImagePayload = (ctx) => ({
6474
6489
  imageSize: ctx.resolution ?? "1K",
6475
6490
  ...buildThinkingConfig(ctx)
6476
6491
  });
6477
- var buildSpicyMayoPayload = (ctx) => ({
6492
+ var buildNanoBanana21Payload = (ctx) => ({
6478
6493
  prompt: ctx.prompt,
6479
- model: "spicy-mayo",
6494
+ model: "gemini-nano-banana-2.1",
6480
6495
  count: ctx.count ?? 1,
6481
6496
  ...ctx.seed != null ? { seed: ctx.seed } : {},
6482
6497
  ...ctx.imageUrls?.length ? { imageUrls: ctx.imageUrls } : {},
6483
6498
  aspectRatio: ctx.aspectRatio ?? "1:1",
6484
- imageSize: "1K",
6499
+ imageSize: ctx.resolution ?? "1K",
6485
6500
  ...buildThinkingConfig(ctx)
6486
6501
  });
6487
6502
  function inferMimeType2(url) {
@@ -6562,7 +6577,7 @@ var thinkingBudgetParam = {
6562
6577
  descriptor: { kind: "range", min: 128, max: 24576, step: 128, default: 128 }
6563
6578
  }
6564
6579
  };
6565
- var spicyMayoThinkingParam = {
6580
+ var nanoBanana21ThinkingParam = {
6566
6581
  thinkingLevel: {
6567
6582
  label: "Thinking",
6568
6583
  descriptor: {
@@ -6580,31 +6595,28 @@ var spicyMayoThinkingParam = {
6580
6595
  var { MODELS: MODELS22 } = defineModels("google", [
6581
6596
  // ── Image ─────────────────────────────────────────────────────────
6582
6597
  {
6583
- id: "spicy-mayo",
6584
- name: "Spicy Mayo",
6585
- addedAt: "2026-10-02",
6586
- // Confidential early access at the vendor, authorized for named projects
6587
- // only — stage until the co-launch clears it for prod.
6588
- release: "preview",
6598
+ id: "gemini-nano-banana-2.1",
6599
+ name: "Nano Banana 2.1",
6600
+ addedAt: "2026-10-06",
6589
6601
  workflow: "gemini/v2/images",
6590
- buildPayload: buildSpicyMayoPayload,
6591
- // Measured end-to-end against stage at 1K/1:1: 9s to generate, 13s to edit
6592
- // with two reference images. Rounded up — vendor testing capacity is capped.
6593
- estimatedTime: 15,
6602
+ buildPayload: buildNanoBanana21Payload,
6603
+ // Measured end-to-end through the worker (generation plus the CDN upload a caller
6604
+ // waits on), two runs per tier: 1K 15-17s, 2K 28-29s, 4K 45-50s. Rounded up.
6605
+ estimatedTime: { "1K": 18, "2K": 30, "4K": 50 },
6594
6606
  mode: "image",
6595
6607
  inputType: "t2i",
6596
- modelId: "spicy-mayo",
6608
+ modelId: "gemini-nano-banana-2.1",
6597
6609
  badge: ["fast"],
6598
6610
  description: "Fast Google image generation and editing with multi-image references.",
6599
- // Only the 1K tier is priced, so no `resolution` param: the builder pins
6600
- // imageSize and anything else is a 400 from the worker.
6601
- features: [feat("Multi-Image Input", "input"), feat("1K", "resolution")],
6611
+ features: [feat("Multi-Image Input", "input"), feat("4K", "resolution")],
6602
6612
  paramConfig: {
6603
6613
  ...params.prompt(),
6604
6614
  ...params.aspectRatio([...GEMINI_AR_WIDE], "1:1"),
6615
+ // 0.5K is rejected by the vendor; 1K/2K/4K each genuinely scale the output.
6616
+ ...params.resolution(["1K", "2K", "4K"], "1K"),
6605
6617
  ...params.count(),
6606
6618
  ...params.seed(),
6607
- ...spicyMayoThinkingParam,
6619
+ ...nanoBanana21ThinkingParam,
6608
6620
  ...params.imageInput(14, "Source Images")
6609
6621
  }
6610
6622
  },
@@ -7674,7 +7686,7 @@ var buildElevenLabsDialoguePayload = (catalogId, modelId) => (input) => {
7674
7686
  };
7675
7687
  function dialogueCharacterCap(catalogId) {
7676
7688
  const descriptor = MODELS24.find((m) => m.id === catalogId)?.paramConfig.dialogue?.descriptor;
7677
- const text = descriptor?.kind === "object" ? descriptor.fields.text : void 0;
7689
+ const text = descriptor?.kind === "object" ? descriptor.fields?.text : void 0;
7678
7690
  const cap = text && "maxLength" in text ? text.maxLength : void 0;
7679
7691
  if (typeof cap !== "number") {
7680
7692
  throw new Error(`${catalogId}: dialogue entry declares no per-line maxLength to derive the cap from`);
@@ -10652,6 +10664,77 @@ registerEditPayloads(MODELS37, {
10652
10664
  "muse-image-1.0": buildMuseImageEditPayload
10653
10665
  });
10654
10666
 
10667
+ // src/vendors/catalog/typesafe.ts
10668
+ var evaluateOutputSchema = {
10669
+ parse(output) {
10670
+ const obj = output;
10671
+ if (!obj || typeof obj.answers !== "object" || obj.answers == null) {
10672
+ throw new Error("No answers in TypeSafe evaluate response");
10673
+ }
10674
+ return output;
10675
+ }
10676
+ };
10677
+ var { MODELS: MODELS38 } = defineModels("typesafe", [
10678
+ {
10679
+ id: "typesafe-evaluate",
10680
+ name: "Jev",
10681
+ workflow: "typesafe/v1/systemone/evaluate",
10682
+ addedAt: "2026-10-05",
10683
+ modelId: "jev-latest",
10684
+ estimatedTime: 6,
10685
+ badge: ["new"],
10686
+ mode: "json",
10687
+ inputType: "t2t",
10688
+ outputSchema: evaluateOutputSchema,
10689
+ description: "Evaluate content against named questions (yes/no, choice, score) and get structured answers back.",
10690
+ features: [feat("Structured Output", "characteristic")],
10691
+ paramConfig: {
10692
+ ...p.text("state", { label: "Content", required: true }),
10693
+ questions: {
10694
+ label: "Questions",
10695
+ required: true,
10696
+ // Dictionary of caller-chosen question ids → question objects.
10697
+ descriptor: {
10698
+ kind: "object",
10699
+ additionalProperties: {
10700
+ kind: "object",
10701
+ fields: {
10702
+ type: {
10703
+ kind: "enum",
10704
+ valueType: "string",
10705
+ default: "noul",
10706
+ required: true,
10707
+ options: [
10708
+ { id: "noul", label: "Yes/No" },
10709
+ { id: "choice", label: "Choice" },
10710
+ { id: "score", label: "Score" }
10711
+ ]
10712
+ },
10713
+ // Plain string or a structured instruction object — the shape is
10714
+ // vendor-defined (see https://docs.typesafe.ai/api), so only
10715
+ // presence is enforced here.
10716
+ instructions: { kind: "unknown", required: true }
10717
+ },
10718
+ // Choice options, score bounds, etc. are question-type-specific —
10719
+ // see https://docs.typesafe.ai/api; pass them through unvalidated.
10720
+ additionalProperties: { kind: "unknown" }
10721
+ }
10722
+ }
10723
+ }
10724
+ }
10725
+ }
10726
+ ]);
10727
+
10728
+ // src/vendors/catalog/typesafe.payloads.ts
10729
+ var buildEvaluatePayload = (input) => ({
10730
+ state: input.state,
10731
+ model: "jev-latest",
10732
+ questions: input.questions
10733
+ });
10734
+ registerPayloads(MODELS38, {
10735
+ "typesafe-evaluate": buildEvaluatePayload
10736
+ });
10737
+
10655
10738
  // src/vendors/catalog/creatify.payloads.ts
10656
10739
  var buildCreatifyBorealPayload = (input) => ({
10657
10740
  prompt: input.prompt,
@@ -10806,7 +10889,8 @@ var ALL_MODELS = [
10806
10889
  ...MODELS34,
10807
10890
  ...MODELS35,
10808
10891
  ...MODELS36,
10809
- ...MODELS37
10892
+ ...MODELS37,
10893
+ ...MODELS38
10810
10894
  ];
10811
10895
  var getModelsByMode = (mode, includeHidden = false) => ALL_MODELS.filter((m) => m.mode === mode && (includeHidden || isVisibleForReleases(m)));
10812
10896
 
@@ -12352,6 +12436,24 @@ function parseTextResult(completed, model) {
12352
12436
  }
12353
12437
  return { text, model: model.id, raw: completed.raw ?? completed.result, usage: completed.usage };
12354
12438
  }
12439
+ function parseRunResult(completed, model, contract) {
12440
+ throwIfErrorResult(completed.result, model.name);
12441
+ throwIfErrorResult(completed.raw, model.name);
12442
+ const result = contract?.output ? contract.output.parse(completed.result) : completed.result;
12443
+ if (result == null) {
12444
+ throw new ApiError(`${model.name}: unexpected response \u2014 empty result`, {
12445
+ status: 502,
12446
+ code: "invalid_response"
12447
+ });
12448
+ }
12449
+ return {
12450
+ result,
12451
+ status: "COMPLETED",
12452
+ usage: completed.usage,
12453
+ // Sync executions have no job id (nothing to poll) — omit rather than ''.
12454
+ ...completed.handle.id ? { id: completed.handle.id } : {}
12455
+ };
12456
+ }
12355
12457
 
12356
12458
  // src/core/limits.ts
12357
12459
  var MAX_DRIVE_PROMPT_LENGTH = 18e3;
@@ -13128,6 +13230,7 @@ var GenerationEventType = {
13128
13230
  };
13129
13231
 
13130
13232
  // src/client/index.ts
13233
+ var MEDIA_MODES = /* @__PURE__ */ new Set(["video", "image", "audio"]);
13131
13234
  var MODE_POLL_DEFAULTS = {
13132
13235
  video: { intervalMs: 2e3, maxAttempts: 1800 },
13133
13236
  // 2s × 1800 = 1 hour
@@ -13135,7 +13238,9 @@ var MODE_POLL_DEFAULTS = {
13135
13238
  // 1s × 1200 = 20 min
13136
13239
  audio: { intervalMs: 1e3, maxAttempts: 1200 },
13137
13240
  // 1s × 1200 = 20 min
13138
- text: { intervalMs: 1e3, maxAttempts: 1200 }
13241
+ text: { intervalMs: 1e3, maxAttempts: 1200 },
13242
+ // 1s × 1200 = 20 min
13243
+ json: { intervalMs: 1e3, maxAttempts: 1200 }
13139
13244
  // 1s × 1200 = 20 min
13140
13245
  };
13141
13246
  function resolvePollOptions(model, overrides) {
@@ -13193,13 +13298,16 @@ function createClient(config) {
13193
13298
  if (!transport.submit) throw unsupportedTransport("submit");
13194
13299
  if (!transport.poll) throw unsupportedTransport("polling");
13195
13300
  }
13301
+ function isMediaModel(model) {
13302
+ return MEDIA_MODES.has(model.mode);
13303
+ }
13196
13304
  function assertMediaModel(model) {
13197
- if (model.mode === "text") {
13198
- throw new ApiError(`${model.name} is a text model \u2014 use generateText() instead.`, {
13199
- status: 400,
13200
- code: "wrong_model_mode"
13201
- });
13202
- }
13305
+ if (isMediaModel(model)) return;
13306
+ const alternative = model.mode === "text" ? "generateText()" : "run()";
13307
+ throw new ApiError(`${model.name} is a ${model.mode} model \u2014 use ${alternative} instead.`, {
13308
+ status: 400,
13309
+ code: "wrong_model_mode"
13310
+ });
13203
13311
  }
13204
13312
  async function submitJob(workflow, payload, signal) {
13205
13313
  if (signal?.aborted) {
@@ -13282,6 +13390,21 @@ function createClient(config) {
13282
13390
  }
13283
13391
  return {
13284
13392
  // ── Simple path ──────────────────────────────────────────────────
13393
+ /**
13394
+ * Run any model by id and get the task result back, generically — the
13395
+ * model-id counterpart of `ai.apis.run()`. Works on every model: builds
13396
+ * and validates the payload from paramConfig, executes the workflow
13397
+ * (sync or async), applies the model's `outputSchema` when declared, and
13398
+ * returns the task result as-is — no media-URL or text extraction, no
13399
+ * Drive save, no options injection. The only generation surface for
13400
+ * json-mode (structured-output) models.
13401
+ */
13402
+ async run(model, params2, options) {
13403
+ const resolved = resolveModel(model);
13404
+ const { workflow, payload, contract } = prepareRequest(resolved, params2);
13405
+ const completed = await executeModel(resolved, workflow, payload, options);
13406
+ return parseRunResult(completed, resolved, contract);
13407
+ },
13285
13408
  /**
13286
13409
  * Generate content using a model.
13287
13410
  *
@@ -13520,6 +13643,7 @@ var Gemini37Flash = "gemini-3.7-flash";
13520
13643
  var Gemini38Flash = "gemini-3.8-flash";
13521
13644
  var Gemini38FlashLiteTts = "gemini-3.8-flash-lite-tts";
13522
13645
  var Gemini38FlashTts = "gemini-3.8-flash-tts";
13646
+ var GeminiNanoBanana21 = "gemini-nano-banana-2.1";
13523
13647
  var GeminiOmni11FlashPreview = "gemini-omni-1.1-flash-preview";
13524
13648
  var GeminiOmniFlashPreview = "gemini-omni-flash-preview";
13525
13649
  var Gpt41Mini = "gpt-4.1-mini";
@@ -13702,9 +13826,9 @@ var Seedream47 = "seedream-4.7";
13702
13826
  var Seedream50Flash = "seedream-5.0-flash";
13703
13827
  var Seedream50Lite = "seedream-5.0-lite";
13704
13828
  var Seedream50Pro = "seedream-5.0-pro";
13705
- var SpicyMayo = "spicy-mayo";
13706
13829
  var TopazUpscaleImage = "topaz-upscale-image";
13707
13830
  var TopazUpscaleVideo = "topaz-upscale-video";
13831
+ var TypesafeEvaluate = "typesafe-evaluate";
13708
13832
  var VeedFabricV1 = "veed-fabric-v1";
13709
13833
  var VeedFabricV1Fast = "veed-fabric-v1-fast";
13710
13834
  var Veo31 = "veo-3.1";
@@ -13776,6 +13900,7 @@ var Models = {
13776
13900
  Gemini38Flash,
13777
13901
  Gemini38FlashLiteTts,
13778
13902
  Gemini38FlashTts,
13903
+ GeminiNanoBanana21,
13779
13904
  GeminiOmni11FlashPreview,
13780
13905
  GeminiOmniFlashPreview,
13781
13906
  Gpt41Mini,
@@ -13958,9 +14083,9 @@ var Models = {
13958
14083
  Seedream50Flash,
13959
14084
  Seedream50Lite,
13960
14085
  Seedream50Pro,
13961
- SpicyMayo,
13962
14086
  TopazUpscaleImage,
13963
14087
  TopazUpscaleVideo,
14088
+ TypesafeEvaluate,
13964
14089
  VeedFabricV1,
13965
14090
  VeedFabricV1Fast,
13966
14091
  Veo31,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "6.25.0",
3
+ "version": "6.29.0",
4
4
  "type": "module",
5
5
  "description": "Type-safe SDK for 100+ AI models — image, video, audio, and text generation with Picsart",
6
6
  "license": "MIT",