@picsart/ai-sdk 6.17.0 → 6.18.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.js CHANGED
@@ -736,14 +736,19 @@ var p = {
736
736
  }
737
737
  };
738
738
  },
739
+ /** Options are bare seconds (`[5, 10]`) or `{ id, label }` pairs when a value
740
+ * needs a friendly label — e.g. `{ id: -1, label: 'Auto' }`. */
739
741
  duration(opts, def) {
742
+ const normalized = opts.map(
743
+ (opt) => typeof opt === "object" ? opt : { id: opt }
744
+ );
740
745
  return {
741
746
  duration: {
742
747
  descriptor: {
743
748
  kind: "enum",
744
749
  valueType: "number",
745
- options: opts.map((id) => ({ id })),
746
- default: def ?? opts[0]
750
+ options: normalized,
751
+ default: def ?? normalized[0].id
747
752
  }
748
753
  }
749
754
  };
@@ -4517,8 +4522,14 @@ var buildSeedance25VideoExtendPayloadFor = (modelAlias) => withSeedance25DraftMo
4517
4522
  var SEEDANCE_AR = ["16:9", "9:16", "1:1", "4:3", "3:4", "21:9", "adaptive"];
4518
4523
  var SEEDANCE_25_FORMATS = ["mp4", "mov"];
4519
4524
  var SEEDANCE_25_COLOR_DEPTHS = ["10bit", "8bit"];
4520
- var SEEDANCE_V2_DURATIONS = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
4521
- var SEEDANCE_25_DURATION = { min: 4, max: 30 };
4525
+ var seedanceDurations = (min, max, withAuto = true) => [
4526
+ ...withAuto ? [{ id: -1, label: "Auto" }] : [],
4527
+ ...Array.from({ length: max - min + 1 }, (_, i) => min + i)
4528
+ ];
4529
+ var SEEDANCE_25_DURATIONS = seedanceDurations(4, 30);
4530
+ var SEEDANCE_20_DURATIONS = seedanceDurations(4, 15);
4531
+ var SEEDANCE_15_DURATIONS = seedanceDurations(4, 12);
4532
+ var SEEDANCE_10_DURATIONS = seedanceDurations(2, 12, false);
4522
4533
  var seedance25DraftParam = p.boolean("draft", false, "Draft");
4523
4534
  var seedance25DraftTaskParam = {
4524
4535
  draftTask: {
@@ -4555,7 +4566,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4555
4566
  ...params.prompt({ required: false }),
4556
4567
  ...params.aspectRatio(SEEDANCE_AR),
4557
4568
  ...params.resolution(["480p", "720p", "1080p"], "1080p"),
4558
- ...params.durationRange(SEEDANCE_25_DURATION.min, SEEDANCE_25_DURATION.max, 5),
4569
+ ...params.duration(SEEDANCE_25_DURATIONS, 5),
4559
4570
  ...params.generateAudio(),
4560
4571
  ...params.returnLastFrame(),
4561
4572
  ...p.enum("outputFormat", SEEDANCE_25_FORMATS, "mp4", { label: "Format" }),
@@ -4594,7 +4605,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4594
4605
  ...params.prompt({ required: false }),
4595
4606
  ...params.aspectRatio(SEEDANCE_AR),
4596
4607
  ...params.resolution(["480p", "720p", "1080p"], "1080p"),
4597
- ...params.durationRange(SEEDANCE_25_DURATION.min, SEEDANCE_25_DURATION.max, 5),
4608
+ ...params.duration(SEEDANCE_25_DURATIONS, 5),
4598
4609
  ...params.generateAudio(),
4599
4610
  ...params.returnLastFrame(),
4600
4611
  ...p.enum("outputFormat", SEEDANCE_25_FORMATS, "mp4", { label: "Format" }),
@@ -4692,7 +4703,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4692
4703
  // duration stays user-selectable.
4693
4704
  ...params.aspectRatio(["adaptive"]),
4694
4705
  ...params.resolution(["480p", "720p", "1080p"], "1080p"),
4695
- ...params.durationRange(SEEDANCE_25_DURATION.min, SEEDANCE_25_DURATION.max, 15),
4706
+ ...params.duration(SEEDANCE_25_DURATIONS, 15),
4696
4707
  ...params.generateAudio(),
4697
4708
  ...p.enum("outputFormat", SEEDANCE_25_FORMATS, "mp4", { label: "Format" }),
4698
4709
  ...p.enum("colorDepth", SEEDANCE_25_COLOR_DEPTHS, "10bit", { label: "Color Depth" }),
@@ -4721,7 +4732,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4721
4732
  // duration stays user-selectable.
4722
4733
  ...params.aspectRatio(["adaptive"]),
4723
4734
  ...params.resolution(["480p", "720p", "1080p"], "1080p"),
4724
- ...params.durationRange(SEEDANCE_25_DURATION.min, SEEDANCE_25_DURATION.max, 15),
4735
+ ...params.duration(SEEDANCE_25_DURATIONS, 15),
4725
4736
  ...params.generateAudio(),
4726
4737
  ...p.enum("outputFormat", SEEDANCE_25_FORMATS, "mp4", { label: "Format" }),
4727
4738
  ...p.enum("colorDepth", SEEDANCE_25_COLOR_DEPTHS, "10bit", { label: "Color Depth" }),
@@ -4747,7 +4758,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4747
4758
  ...params.prompt(),
4748
4759
  ...params.aspectRatio(SEEDANCE_AR),
4749
4760
  ...params.resolution(["480p", "720p", "1080p", "4k"], "720p"),
4750
- ...params.duration(SEEDANCE_V2_DURATIONS, 10),
4761
+ ...params.duration(SEEDANCE_20_DURATIONS, 10),
4751
4762
  ...params.generateAudio(),
4752
4763
  ...params.returnLastFrame(),
4753
4764
  // Reference roles map directly to backend `reference_*` content entries.
@@ -4781,7 +4792,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4781
4792
  ...params.prompt(),
4782
4793
  ...params.aspectRatio(SEEDANCE_AR),
4783
4794
  ...params.resolution(["480p", "720p", "1080p", "4k"], "720p"),
4784
- ...params.duration(SEEDANCE_V2_DURATIONS, 10),
4795
+ ...params.duration(SEEDANCE_20_DURATIONS, 10),
4785
4796
  ...params.generateAudio(),
4786
4797
  ...params.returnLastFrame(),
4787
4798
  // Reference roles map directly to backend `reference_*` content entries.
@@ -4811,7 +4822,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4811
4822
  ...params.prompt(),
4812
4823
  ...params.aspectRatio(SEEDANCE_AR),
4813
4824
  ...params.resolution(["480p", "720p"], "720p"),
4814
- ...params.duration(SEEDANCE_V2_DURATIONS, 10),
4825
+ ...params.duration(SEEDANCE_20_DURATIONS, 10),
4815
4826
  ...params.generateAudio(),
4816
4827
  ...params.returnLastFrame(),
4817
4828
  // Reference roles map directly to backend `reference_*` content entries.
@@ -4841,7 +4852,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4841
4852
  ...params.prompt(),
4842
4853
  ...params.aspectRatio(SEEDANCE_AR),
4843
4854
  ...params.resolution(["480p", "720p"], "720p"),
4844
- ...params.duration(SEEDANCE_V2_DURATIONS, 10),
4855
+ ...params.duration(SEEDANCE_20_DURATIONS, 10),
4845
4856
  ...params.generateAudio(),
4846
4857
  ...params.returnLastFrame(),
4847
4858
  // Reference roles map directly to backend `reference_*` content entries.
@@ -4870,7 +4881,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4870
4881
  ...params.prompt(),
4871
4882
  ...params.aspectRatio(SEEDANCE_AR),
4872
4883
  ...params.resolution(["480p", "720p", "1080p", "4k"], "720p"),
4873
- ...params.duration(SEEDANCE_V2_DURATIONS, 5),
4884
+ ...params.duration(SEEDANCE_20_DURATIONS, 5),
4874
4885
  ...params.generateAudio(),
4875
4886
  ...params.returnLastFrame(),
4876
4887
  // Every limit rides in `bounds`; the positional maxDuration / maxShortSide
@@ -4897,7 +4908,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4897
4908
  ...params.prompt(),
4898
4909
  ...params.aspectRatio(SEEDANCE_AR),
4899
4910
  ...params.resolution(["480p", "720p", "1080p", "4k"], "720p"),
4900
- ...params.duration(SEEDANCE_V2_DURATIONS, 5),
4911
+ ...params.duration(SEEDANCE_20_DURATIONS, 5),
4901
4912
  ...params.generateAudio(),
4902
4913
  ...params.returnLastFrame(),
4903
4914
  // Every limit rides in `bounds`; the positional maxDuration / maxShortSide
@@ -4923,7 +4934,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4923
4934
  ...params.prompt(),
4924
4935
  ...params.aspectRatio(SEEDANCE_AR),
4925
4936
  ...params.resolution(["480p", "720p"], "720p"),
4926
- ...params.duration(SEEDANCE_V2_DURATIONS, 5),
4937
+ ...params.duration(SEEDANCE_20_DURATIONS, 5),
4927
4938
  ...params.generateAudio(),
4928
4939
  ...params.returnLastFrame(),
4929
4940
  // Every limit rides in `bounds`; the positional maxDuration / maxShortSide
@@ -4949,7 +4960,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4949
4960
  ...params.prompt(),
4950
4961
  ...params.aspectRatio(SEEDANCE_AR),
4951
4962
  ...params.resolution(["480p", "720p"], "720p"),
4952
- ...params.duration(SEEDANCE_V2_DURATIONS, 5),
4963
+ ...params.duration(SEEDANCE_20_DURATIONS, 5),
4953
4964
  ...params.generateAudio(),
4954
4965
  ...params.returnLastFrame(),
4955
4966
  // Every limit rides in `bounds`; the positional maxDuration / maxShortSide
@@ -4975,7 +4986,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4975
4986
  ...params.prompt(),
4976
4987
  ...params.aspectRatio(SEEDANCE_AR),
4977
4988
  ...params.resolution(["480p", "720p", "1080p", "4k"], "720p"),
4978
- ...params.duration(SEEDANCE_V2_DURATIONS, 15),
4989
+ ...params.duration(SEEDANCE_20_DURATIONS, 15),
4979
4990
  ...params.generateAudio(),
4980
4991
  ...params.videoInputs(3, "Source Videos", true, SEEDANCE_20_VIDEO_BOUNDS)
4981
4992
  }
@@ -4998,7 +5009,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
4998
5009
  ...params.prompt(),
4999
5010
  ...params.aspectRatio(SEEDANCE_AR),
5000
5011
  ...params.resolution(["480p", "720p", "1080p", "4k"], "720p"),
5001
- ...params.duration(SEEDANCE_V2_DURATIONS, 15),
5012
+ ...params.duration(SEEDANCE_20_DURATIONS, 15),
5002
5013
  ...params.generateAudio(),
5003
5014
  ...params.videoInputs(3, "Source Videos", true, SEEDANCE_20_VIDEO_BOUNDS)
5004
5015
  }
@@ -5020,7 +5031,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
5020
5031
  ...params.prompt(),
5021
5032
  ...params.aspectRatio(SEEDANCE_AR),
5022
5033
  ...params.resolution(["480p", "720p"], "720p"),
5023
- ...params.duration(SEEDANCE_V2_DURATIONS, 15),
5034
+ ...params.duration(SEEDANCE_20_DURATIONS, 15),
5024
5035
  ...params.generateAudio(),
5025
5036
  ...params.videoInputs(3, "Source Videos", true, SEEDANCE_20_VIDEO_BOUNDS)
5026
5037
  }
@@ -5042,7 +5053,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
5042
5053
  ...params.prompt(),
5043
5054
  ...params.aspectRatio(SEEDANCE_AR),
5044
5055
  ...params.resolution(["480p", "720p"], "720p"),
5045
- ...params.duration(SEEDANCE_V2_DURATIONS, 15),
5056
+ ...params.duration(SEEDANCE_20_DURATIONS, 15),
5046
5057
  ...params.generateAudio(),
5047
5058
  ...params.videoInputs(3, "Source Videos", true, SEEDANCE_20_VIDEO_BOUNDS)
5048
5059
  }
@@ -5065,7 +5076,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
5065
5076
  ...params.prompt(),
5066
5077
  ...params.aspectRatio(SEEDANCE_AR),
5067
5078
  ...params.resolution(["480p", "720p"], "720p"),
5068
- ...params.duration([4, 5, 8, 10, 12], 5),
5079
+ ...params.duration(SEEDANCE_15_DURATIONS, 5),
5069
5080
  ...params.generateAudio(false),
5070
5081
  ...params.startFrame(),
5071
5082
  ...params.endFrame()
@@ -5089,7 +5100,7 @@ var { MODELS: MODELS13 } = defineModels("seedance", [
5089
5100
  ...params.prompt(),
5090
5101
  ...params.aspectRatio(SEEDANCE_AR),
5091
5102
  ...params.resolution(["480p", "720p", "1080p"], "720p"),
5092
- ...params.duration([5, 10], 5),
5103
+ ...params.duration(SEEDANCE_10_DURATIONS, 5),
5093
5104
  ...params.startFrame("First Frame", true)
5094
5105
  }
5095
5106
  }
@@ -7135,7 +7146,7 @@ var buildElevenLabsVoicePreviewsPayload = (ctx) => ({
7135
7146
  voice_description: ctx.prompt,
7136
7147
  auto_generate_text: true
7137
7148
  });
7138
- var voiceSettingsParams = (withSpeakerBoost) => ({
7149
+ var stabilityAndSimilarityParams = {
7139
7150
  stability: {
7140
7151
  label: "Stability",
7141
7152
  descriptor: { kind: "range", min: 0, max: 1, step: 0.05 }
@@ -7143,7 +7154,10 @@ var voiceSettingsParams = (withSpeakerBoost) => ({
7143
7154
  similarityBoost: {
7144
7155
  label: "Similarity",
7145
7156
  descriptor: { kind: "range", min: 0, max: 1, step: 0.05 }
7146
- },
7157
+ }
7158
+ };
7159
+ var voiceSettingsParams = (withSpeakerBoost) => ({
7160
+ ...stabilityAndSimilarityParams,
7147
7161
  // `style` is taken on GenerationContext by the image models' style *name*,
7148
7162
  // so the vendor's 0–1 style exaggeration gets a key of its own.
7149
7163
  styleExaggeration: {
@@ -7156,21 +7170,69 @@ var voiceSettingsParams = (withSpeakerBoost) => ({
7156
7170
  },
7157
7171
  ...withSpeakerBoost ? { useSpeakerBoost: { label: "Speaker Boost", descriptor: { kind: "boolean", default: true } } } : {}
7158
7172
  });
7159
- var ttsParamConfig = (promptMaxLength, withLanguage) => ({
7160
- // language_code is honoured by eleven_v3 only — the vendor documents it as
7173
+ var ttsParamConfig = (promptMaxLength, opts) => ({
7174
+ // language_code is honoured by eleven_v3 and v4 — the vendor documents it as
7161
7175
  // "not supported for multilingual_v2 models" (silently ignored there).
7162
7176
  // No accent param anywhere: no builder ever read it.
7163
- ...withLanguage ? params.language(false) : {},
7177
+ ...opts.language ? params.language(false) : {},
7164
7178
  ...params.prompt({ maxLength: promptMaxLength }),
7165
7179
  ...params.voiceId([], DEFAULT_VOICE_ID, { catalog: VOICE_CATALOG }),
7166
- ...voiceSettingsParams(true),
7180
+ ...opts.styleControls ? voiceSettingsParams(true) : stabilityAndSimilarityParams,
7167
7181
  // Timings come back beside the audio, for captions and lip sync. Off by
7168
7182
  // default: the vendor answers a different route that inlines the audio as
7169
7183
  // base64, and callers who do not need timings should not pay the decode.
7170
7184
  ...p.boolean("withTimestamps", false, "Character Timings")
7171
7185
  });
7186
+ var dialogueLinesParam = (maxLength) => ({
7187
+ dialogue: {
7188
+ label: "Dialogue",
7189
+ required: true,
7190
+ descriptor: {
7191
+ kind: "object",
7192
+ array: { min: 1 },
7193
+ fields: {
7194
+ // A plain id, not a catalog-bound picker: catalog loading resolves
7195
+ // top-level params only. Every ElevenLabs model shares one voices
7196
+ // task, so a caller lists them from any TTS model — e.g.
7197
+ // `ai.catalogs.voices('eleven-v4')` — and uses the ids here.
7198
+ voiceId: { label: "Voice ID", kind: "text", placeholder: DEFAULT_VOICE_ID },
7199
+ text: { label: "Line", kind: "text", maxLength }
7200
+ }
7201
+ }
7202
+ }
7203
+ });
7172
7204
  var { MODELS: MODELS24 } = defineModels("elevenlabs", [
7173
7205
  // ── TTS ───────────────────────────────────────────────────────────
7206
+ {
7207
+ id: "eleven-v4",
7208
+ name: "Eleven v4",
7209
+ modelId: "eleven_v4",
7210
+ addedAt: "2026-09-29",
7211
+ workflow: "elevenlabs/v1/text-to-speech",
7212
+ estimatedTime: 10,
7213
+ mode: "audio",
7214
+ inputType: "tts",
7215
+ badge: ["new", "popular"],
7216
+ description: "Most expressive voice engine \u2014 audio tags direct the delivery, 90+ languages.",
7217
+ features: [feat("Audio Tags", "characteristic"), feat("90+ Languages", "characteristic"), feat("Creative Control", "characteristic")],
7218
+ paramConfig: ttsParamConfig(1e4, { language: true, styleControls: false })
7219
+ },
7220
+ {
7221
+ // Same engine family tuned for latency; the vendor bills it at half the
7222
+ // per-character rate of eleven_v4.
7223
+ id: "eleven-v4-turbo",
7224
+ name: "Eleven v4 Turbo",
7225
+ modelId: "eleven_v4_turbo",
7226
+ addedAt: "2026-09-29",
7227
+ workflow: "elevenlabs/v1/text-to-speech",
7228
+ estimatedTime: 6,
7229
+ mode: "audio",
7230
+ inputType: "tts",
7231
+ badge: ["new", "fast"],
7232
+ description: "Eleven v4 tuned for speed \u2014 the same audio tags and languages, lower latency.",
7233
+ features: [feat("Audio Tags", "characteristic"), feat("90+ Languages", "characteristic"), feat("Low Latency", "characteristic")],
7234
+ paramConfig: ttsParamConfig(1e4, { language: true, styleControls: false })
7235
+ },
7174
7236
  {
7175
7237
  id: "eleven-v3",
7176
7238
  name: "Eleven v3",
@@ -7181,9 +7243,9 @@ var { MODELS: MODELS24 } = defineModels("elevenlabs", [
7181
7243
  mode: "audio",
7182
7244
  inputType: "tts",
7183
7245
  badge: ["popular"],
7184
- description: "Latest voice engine with expanded tone and pacing control.",
7246
+ description: "Previous-generation expressive engine with expanded tone and pacing control.",
7185
7247
  features: [feat("Experimental", "characteristic"), feat("Creative Control", "characteristic")],
7186
- paramConfig: ttsParamConfig(5e3, true)
7248
+ paramConfig: ttsParamConfig(5e3, { language: true, styleControls: true })
7187
7249
  },
7188
7250
  {
7189
7251
  id: "eleven-multilingual-v2",
@@ -7197,9 +7259,40 @@ var { MODELS: MODELS24 } = defineModels("elevenlabs", [
7197
7259
  badge: ["popular", "fast"],
7198
7260
  description: "Stable multilingual speech across 29+ languages with natural rhythm.",
7199
7261
  features: [feat("Stable", "characteristic"), feat("Professional", "characteristic")],
7200
- paramConfig: ttsParamConfig(1e4, false)
7262
+ paramConfig: ttsParamConfig(1e4, { language: false, styleControls: true })
7201
7263
  },
7202
7264
  // ── Dialogue ──────────────────────────────────────────────────────
7265
+ {
7266
+ // Same pricing key as the v3 dialogue below: the worker bills every
7267
+ // dialogue engine per minute under `eleven-text-to-dialogue`.
7268
+ id: "eleven-dialogue-v4",
7269
+ name: "Eleven Dialogue v4",
7270
+ modelId: "eleven-text-to-dialogue",
7271
+ addedAt: "2026-09-29",
7272
+ workflow: "elevenlabs/v1/text-to-dialogue",
7273
+ estimatedTime: 12,
7274
+ mode: "audio",
7275
+ inputType: "tts",
7276
+ badge: ["new"],
7277
+ description: "Multi-speaker conversation on the v4 engine \u2014 a voice per line, audio tags per line.",
7278
+ features: [feat("Multi-Speaker", "characteristic"), feat("Audio Tags", "characteristic"), feat("90+ Languages", "characteristic")],
7279
+ paramConfig: {
7280
+ ...dialogueLinesParam(1e4),
7281
+ // v4 reads the whole 0–1 range (no presets), and the dialogue endpoint
7282
+ // names its similarity knob `similarity`, not `similarity_boost`.
7283
+ // Both default-less: unset keeps the vendor's 0.5 / 0.75.
7284
+ stability: {
7285
+ label: "Stability",
7286
+ descriptor: { kind: "range", min: 0, max: 1, step: 0.05 }
7287
+ },
7288
+ similarity: {
7289
+ label: "Similarity",
7290
+ descriptor: { kind: "range", min: 0, max: 1, step: 0.05 }
7291
+ },
7292
+ ...params.language(false),
7293
+ ...params.seed(4294967295)
7294
+ }
7295
+ },
7203
7296
  {
7204
7297
  // `modelId` is the pricing-catalog key, not the vendor id: the worker
7205
7298
  // registers the operation as `eleven-text-to-dialogue` while the vendor
@@ -7215,33 +7308,7 @@ var { MODELS: MODELS24 } = defineModels("elevenlabs", [
7215
7308
  description: "Generate a multi-speaker conversation \u2014 a voice per line \u2014 in one take.",
7216
7309
  features: [feat("Multi-Speaker", "characteristic"), feat("Creative Control", "characteristic")],
7217
7310
  paramConfig: {
7218
- // One entry per spoken line, in order. The vendor publishes no cap on the
7219
- // number of lines, so none is invented here.
7220
- //
7221
- // The 5,000-character limit is the vendor's hard cap and applies to the
7222
- // dialogue AS A WHOLE, which a per-field maxLength cannot express — a
7223
- // single line simply cannot exceed it either. Probed against the live
7224
- // `elevenlabs/v1/text-to-dialogue` worker: 10,000 characters are refused
7225
- // with "Request text length (10000) exceeds the maximum text length of
7226
- // 5000 characters", while 2,600 generate fine. The docs' "keep it at or
7227
- // below 2,000" is guidance, not a limit. Note the far end is slow: a
7228
- // 5,000-character dialogue outruns the worker's 120s vendor timeout.
7229
- dialogue: {
7230
- label: "Dialogue",
7231
- required: true,
7232
- descriptor: {
7233
- kind: "object",
7234
- array: { min: 1 },
7235
- fields: {
7236
- // A plain id, not a catalog-bound picker: catalog loading resolves
7237
- // top-level params only. Every ElevenLabs model shares one voices
7238
- // task, so a caller lists them from any TTS model — e.g.
7239
- // `ai.catalogs.voices('eleven-v3')` — and uses the ids here.
7240
- voiceId: { label: "Voice ID", kind: "text", placeholder: DEFAULT_VOICE_ID },
7241
- text: { label: "Line", kind: "text", maxLength: 5e3 }
7242
- }
7243
- }
7244
- },
7311
+ ...dialogueLinesParam(5e3),
7245
7312
  // The vendor takes any 0–1 double and defaults to 0.5; eleven_v3 reads the
7246
7313
  // three presets below, so the picker offers those instead of a slider
7247
7314
  // whose in-between values the engine rounds anyway.
@@ -7517,16 +7584,39 @@ var buildElevenLabsSTSPayload = (modelId) => (input) => ({
7517
7584
  remove_background_noise: input.removeBackgroundNoise ?? false,
7518
7585
  ...voiceSettings(input)
7519
7586
  });
7520
- var buildElevenLabsDialoguePayload = (input) => ({
7521
- conversation: input.dialogue.map((line) => ({
7522
- voice_id: line.voiceId,
7523
- text: line.text
7524
- })),
7525
- model_id: "eleven_v3",
7526
- ...input.stability != null ? { settings: { stability: input.stability } } : {},
7527
- ...input.language ? { language_code: input.language } : {},
7528
- ...input.seed != null ? { seed: input.seed } : {}
7529
- });
7587
+ var buildElevenLabsDialoguePayload = (catalogId, modelId) => (input) => {
7588
+ const cap = dialogueCharacterCap(catalogId);
7589
+ const total = input.dialogue.reduce((sum, line) => sum + line.text.length, 0);
7590
+ if (total > cap) {
7591
+ throw new ApiError(
7592
+ `${catalogId}: the dialogue as a whole exceeds ${cap} characters (got ${total}).`,
7593
+ { status: 400, code: "validation_error" }
7594
+ );
7595
+ }
7596
+ const settings = {
7597
+ ...input.stability != null ? { stability: input.stability } : {},
7598
+ ...input.similarity != null ? { similarity: input.similarity } : {}
7599
+ };
7600
+ return {
7601
+ conversation: input.dialogue.map((line) => ({
7602
+ voice_id: line.voiceId,
7603
+ text: line.text
7604
+ })),
7605
+ model_id: modelId,
7606
+ ...Object.keys(settings).length > 0 ? { settings } : {},
7607
+ ...input.language ? { language_code: input.language } : {},
7608
+ ...input.seed != null ? { seed: input.seed } : {}
7609
+ };
7610
+ };
7611
+ function dialogueCharacterCap(catalogId) {
7612
+ const descriptor = MODELS24.find((m) => m.id === catalogId)?.paramConfig.dialogue?.descriptor;
7613
+ const text = descriptor?.kind === "object" ? descriptor.fields.text : void 0;
7614
+ const cap = text && "maxLength" in text ? text.maxLength : void 0;
7615
+ if (typeof cap !== "number") {
7616
+ throw new Error(`${catalogId}: dialogue entry declares no per-line maxLength to derive the cap from`);
7617
+ }
7618
+ return cap;
7619
+ }
7530
7620
  var buildElevenLabsTranscribePayload = (input) => ({
7531
7621
  audio_url: input.audioUrl,
7532
7622
  ...input.language ? { language_code: input.language } : {},
@@ -7544,11 +7634,14 @@ var buildElevenLabsVideoToMusicPayload = (input) => ({
7544
7634
  });
7545
7635
  registerPayloads(MODELS24, {
7546
7636
  "elevenlabs-music-v2": buildElevenLabsMusicPayload,
7637
+ "eleven-v4": buildElevenLabsTTSPayload("eleven_v4"),
7638
+ "eleven-v4-turbo": buildElevenLabsTTSPayload("eleven_v4_turbo"),
7547
7639
  "eleven-v3": buildElevenLabsTTSPayload("eleven_v3"),
7548
7640
  "eleven-multilingual-v2": buildElevenLabsTTSPayload("eleven_multilingual_v2"),
7549
7641
  "eleven-sts-v2": buildElevenLabsSTSPayload("eleven_english_sts_v2"),
7550
7642
  "eleven-multilingual-sts-v2": buildElevenLabsSTSPayload("eleven_multilingual_sts_v2"),
7551
- "eleven-text-to-dialogue": buildElevenLabsDialoguePayload,
7643
+ "eleven-text-to-dialogue": buildElevenLabsDialoguePayload("eleven-text-to-dialogue", "eleven_v3"),
7644
+ "eleven-dialogue-v4": buildElevenLabsDialoguePayload("eleven-dialogue-v4", "eleven_v4"),
7552
7645
  "eleven-speech-to-text": buildElevenLabsTranscribePayload,
7553
7646
  "eleven-video-to-music": buildElevenLabsVideoToMusicPayload
7554
7647
  });
@@ -13228,6 +13321,7 @@ var ClaudeSonnet5 = "claude-sonnet-5";
13228
13321
  var CreatifyAurora = "creatify-aurora";
13229
13322
  var CreatifyBoreal = "creatify-boreal";
13230
13323
  var ElevenAudioIsolation = "eleven-audio-isolation";
13324
+ var ElevenDialogueV4 = "eleven-dialogue-v4";
13231
13325
  var ElevenDubbing = "eleven-dubbing";
13232
13326
  var ElevenMultilingualStsV2 = "eleven-multilingual-sts-v2";
13233
13327
  var ElevenMultilingualV2 = "eleven-multilingual-v2";
@@ -13235,6 +13329,8 @@ var ElevenSpeechToText = "eleven-speech-to-text";
13235
13329
  var ElevenStsV2 = "eleven-sts-v2";
13236
13330
  var ElevenTextToDialogue = "eleven-text-to-dialogue";
13237
13331
  var ElevenV3 = "eleven-v3";
13332
+ var ElevenV4 = "eleven-v4";
13333
+ var ElevenV4Turbo = "eleven-v4-turbo";
13238
13334
  var ElevenVideoToMusic = "eleven-video-to-music";
13239
13335
  var ElevenVoiceCreate = "eleven-voice-create";
13240
13336
  var ElevenVoiceDesignV2 = "eleven-voice-design-v2";
@@ -13483,6 +13579,7 @@ var Models = {
13483
13579
  CreatifyAurora,
13484
13580
  CreatifyBoreal,
13485
13581
  ElevenAudioIsolation,
13582
+ ElevenDialogueV4,
13486
13583
  ElevenDubbing,
13487
13584
  ElevenMultilingualStsV2,
13488
13585
  ElevenMultilingualV2,
@@ -13490,6 +13587,8 @@ var Models = {
13490
13587
  ElevenStsV2,
13491
13588
  ElevenTextToDialogue,
13492
13589
  ElevenV3,
13590
+ ElevenV4,
13591
+ ElevenV4Turbo,
13493
13592
  ElevenVideoToMusic,
13494
13593
  ElevenVoiceCreate,
13495
13594
  ElevenVoiceDesignV2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "6.17.0",
3
+ "version": "6.18.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",