@picsart/ai-sdk 6.21.2 → 6.21.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +4 -2
  2. package/index.js +21 -28
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -757,18 +757,20 @@ type ModelInputById = {
757
757
  mask?: string;
758
758
  size?: "auto" | "source" | "2048x2048" | "1440x2880" | "2880x1440" | "1664x2496" | "2496x1664" | "1792x2240" | "2240x1792" | "1440x2560" | "2560x1440" | "1600x2560" | "2560x1600" | "1728x2304" | "2304x1728" | "1296x3168" | "3168x1296" | "1152x2944" | "2944x1152" | "1248x3328" | "3328x1248" | "1280x3072" | "3072x1280" | "1024x3072" | "3072x1024" | "1024x1024" | "896x1120" | "1120x896" | "864x1152" | "1152x864" | "832x1248" | "1248x832" | "800x1280" | "1280x800" | "720x1280" | "1280x720" | "720x1440" | "1440x720" | "512x1536" | "1536x512";
759
759
  magicPrompt?: "auto" | "on" | "off";
760
- quality?: "low" | "medium" | "high";
760
+ quality?: "very_low" | "low" | "medium" | "high";
761
761
  count?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
762
762
  seed?: number;
763
+ enableCopyrightDetection?: boolean;
763
764
  };
764
765
  "ideogram-4-5-precise-edit": {
765
766
  prompt: string;
766
767
  startFrame: string;
767
768
  mask?: string;
768
769
  imageUrls?: string[];
769
- quality?: "low" | "medium" | "high" | "very_high";
770
+ quality?: "very_low" | "low" | "medium" | "high";
770
771
  count?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
771
772
  seed?: number;
773
+ enableCopyrightDetection?: boolean;
772
774
  };
773
775
  "ideogram-character": {
774
776
  prompt: string;
package/index.js CHANGED
@@ -8082,10 +8082,12 @@ var ideogram45MagicPromptParam = {
8082
8082
  }
8083
8083
  };
8084
8084
  var IDEOGRAM_45_COUNTS = [1, 2, 3, 4, 5, 6, 7, 8];
8085
+ var IDEOGRAM_45_QUALITIES = ["very_low", "low", "medium", "high"];
8085
8086
  var ideogram45Constraints = [
8086
8087
  { when: { imageUrls: { exists: false } }, then: {
8087
8088
  size: { allowed: ["auto", ...IDEOGRAM_45_T2I_SIZES] },
8088
- mask: { disabled: true, reason: "A mask needs a source image." }
8089
+ mask: { disabled: true, reason: "A mask needs a source image." },
8090
+ quality: { allowed: ["low", "medium", "high"], reason: "Very low quality needs a source image." }
8089
8091
  } },
8090
8092
  { when: { imageUrls: { exists: true } }, then: {
8091
8093
  size: { allowed: ["auto", "source"], reason: 'With input images the size is "auto" or the source image size.' }
@@ -8094,11 +8096,6 @@ var ideogram45Constraints = [
8094
8096
  size: { disabled: true, reason: "A masked edit keeps the source image size." }
8095
8097
  } }
8096
8098
  ];
8097
- var ideogram45PreciseEditConstraints = [
8098
- { when: { quality: { is: "very_high" } }, then: {
8099
- count: { allowed: [1, 2, 3, 4], reason: "Very high quality returns at most 4 images." }
8100
- } }
8101
- ];
8102
8099
  var { MODELS: MODELS26 } = defineModels("ideogram", [
8103
8100
  {
8104
8101
  id: "ideogram-4-5",
@@ -8119,9 +8116,10 @@ var { MODELS: MODELS26 } = defineModels("ideogram", [
8119
8116
  ...ideogram45MaskParam,
8120
8117
  ...p.size(["auto", "source", ...IDEOGRAM_45_T2I_SIZES], "auto"),
8121
8118
  ...ideogram45MagicPromptParam,
8122
- ...p.quality(["low", "medium", "high"], "high"),
8119
+ ...p.quality(IDEOGRAM_45_QUALITIES, "high"),
8123
8120
  ...params.count(IDEOGRAM_45_COUNTS, 1),
8124
- ...params.seed()
8121
+ ...params.seed(),
8122
+ ...p.boolean("enableCopyrightDetection", false, "Copyright Detection")
8125
8123
  }
8126
8124
  },
8127
8125
  {
@@ -8134,16 +8132,16 @@ var { MODELS: MODELS26 } = defineModels("ideogram", [
8134
8132
  inputType: "i2i",
8135
8133
  description: "Ideogram 4.5 precise edit \u2014 change one area and keep the rest of the image pixel-intact, optionally with a mask and reference images.",
8136
8134
  features: [feat("Precise Edit", "input"), feat("Masked Edit", "input"), feat("Reference Images", "input")],
8137
- constraints: ideogram45PreciseEditConstraints,
8138
8135
  paramConfig: {
8139
8136
  ...params.prompt({ maxLength: 1e4 }),
8140
8137
  ...params.startFrame("Source Image", true, IDEOGRAM_45_IMAGE_BOUNDS),
8141
8138
  ...ideogram45MaskParam,
8142
8139
  // With a mask the vendor allows at most 3 references.
8143
8140
  ...params.imageInput(4, "Reference Images", false, "reference", IDEOGRAM_45_IMAGE_BOUNDS),
8144
- ...p.quality(["low", "medium", "high", "very_high"], "high"),
8141
+ ...p.quality(IDEOGRAM_45_QUALITIES, "medium"),
8145
8142
  ...params.count(IDEOGRAM_45_COUNTS, 1),
8146
- ...params.seed()
8143
+ ...params.seed(),
8144
+ ...p.boolean("enableCopyrightDetection", false, "Copyright Detection")
8147
8145
  }
8148
8146
  },
8149
8147
  {
@@ -8345,14 +8343,11 @@ var { MODELS: MODELS26 } = defineModels("ideogram", [
8345
8343
  // src/vendors/catalog/ideogram.payloads.ts
8346
8344
  var GENERATE_MAX_IMAGES_WITH_MASK = 4;
8347
8345
  var PRECISE_EDIT_MAX_REFERENCES_WITH_MASK = 3;
8348
- var VERY_HIGH_MAX_COUNT = 4;
8349
8346
  function assertMaskedImageLimit(model, count, max, what) {
8350
- if (count > max) {
8351
- throw new ApiError(`${model}: with a mask, use at most ${max} ${what} (got ${count}).`, {
8352
- status: 400,
8353
- code: "validation_error"
8354
- });
8355
- }
8347
+ if (count > max) throw invalid2(`${model}: with a mask, use at most ${max} ${what} (got ${count}).`);
8348
+ }
8349
+ function invalid2(message) {
8350
+ return new ApiError(message, { status: 400, code: "validation_error" });
8356
8351
  }
8357
8352
  function ideogram45Size(size, hasImages, hasMask) {
8358
8353
  if (!size || hasMask) return void 0;
@@ -8364,15 +8359,18 @@ var buildIdeogram45Payload = (input) => {
8364
8359
  const mask = images && input.mask ? input.mask : void 0;
8365
8360
  if (mask) assertMaskedImageLimit("Ideogram 4.5", images.length, GENERATE_MAX_IMAGES_WITH_MASK, "images");
8366
8361
  const size = ideogram45Size(input.size, !!images, !!mask);
8362
+ if (input.quality === "very_low" && !images) throw invalid2("Ideogram 4.5: very_low quality needs a source image.");
8367
8363
  return {
8368
8364
  prompt: input.prompt,
8369
8365
  ...images ? { images } : {},
8370
8366
  ...mask ? { mask } : {},
8371
8367
  ...size ? { size } : {},
8372
8368
  ...input.magicPrompt ? { magic_prompt: input.magicPrompt } : {},
8373
- quality: input.quality ?? "high",
8369
+ // Vendor default: medium with source images, high without.
8370
+ quality: input.quality ?? (images ? "medium" : "high"),
8374
8371
  num_images: input.count ?? 1,
8375
- ...input.seed != null ? { seed: input.seed } : {}
8372
+ ...input.seed != null ? { seed: input.seed } : {},
8373
+ ...input.enableCopyrightDetection ? { enable_copyright_detection: true } : {}
8376
8374
  };
8377
8375
  };
8378
8376
  var buildIdeogram45PreciseEditPayload = (input) => {
@@ -8384,20 +8382,15 @@ var buildIdeogram45PreciseEditPayload = (input) => {
8384
8382
  "reference images"
8385
8383
  );
8386
8384
  }
8387
- if (input.quality === "very_high" && (input.count ?? 1) > VERY_HIGH_MAX_COUNT) {
8388
- throw new ApiError(
8389
- `Ideogram 4.5 Precise Edit: very_high quality returns at most ${VERY_HIGH_MAX_COUNT} images (got ${input.count}).`,
8390
- { status: 400, code: "validation_error" }
8391
- );
8392
- }
8393
8385
  return {
8394
8386
  image: input.startFrame,
8395
8387
  prompt: input.prompt,
8396
8388
  ...input.mask ? { mask: input.mask } : {},
8397
8389
  ...input.imageUrls?.length ? { reference_images: input.imageUrls } : {},
8398
- quality: input.quality ?? "high",
8390
+ quality: input.quality ?? "medium",
8399
8391
  num_images: input.count ?? 1,
8400
- ...input.seed != null ? { seed: input.seed } : {}
8392
+ ...input.seed != null ? { seed: input.seed } : {},
8393
+ ...input.enableCopyrightDetection ? { enable_copyright_detection: true } : {}
8401
8394
  };
8402
8395
  };
8403
8396
  registerPayloads(MODELS26, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "6.21.2",
3
+ "version": "6.21.3",
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",