@picsart/ai-sdk 6.22.0 → 6.22.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.
Files changed (3) hide show
  1. package/index.d.ts +2 -1
  2. package/index.js +39 -51
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -778,7 +778,8 @@ type ModelInputById = {
778
778
  prompt: string;
779
779
  imageUrls?: string[];
780
780
  mask?: string;
781
- 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";
781
+ aspectRatio?: "auto" | "source" | "1:1" | "16:9" | "9:16" | "4:3" | "3:4" | "3:2" | "2:3" | "5:4" | "4:5" | "8:5" | "5:8" | "2:1" | "1:2" | "3:1" | "1:3";
782
+ resolution?: "1K" | "2K";
782
783
  magicPrompt?: "auto" | "on" | "off";
783
784
  quality?: "very_low" | "low" | "medium" | "high";
784
785
  count?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
package/index.js CHANGED
@@ -8019,45 +8019,24 @@ var IDEOGRAM_45_IMAGE_BOUNDS = {
8019
8019
  minAspectRatio: 1 / 6,
8020
8020
  maxAspectRatio: 6
8021
8021
  };
8022
- var IDEOGRAM_45_T2I_SIZES = [
8023
- "2048x2048",
8024
- "1440x2880",
8025
- "2880x1440",
8026
- "1664x2496",
8027
- "2496x1664",
8028
- "1792x2240",
8029
- "2240x1792",
8030
- "1440x2560",
8031
- "2560x1440",
8032
- "1600x2560",
8033
- "2560x1600",
8034
- "1728x2304",
8035
- "2304x1728",
8036
- "1296x3168",
8037
- "3168x1296",
8038
- "1152x2944",
8039
- "2944x1152",
8040
- "1248x3328",
8041
- "3328x1248",
8042
- "1280x3072",
8043
- "3072x1280",
8044
- "1024x3072",
8045
- "3072x1024",
8046
- "1024x1024",
8047
- "896x1120",
8048
- "1120x896",
8049
- "864x1152",
8050
- "1152x864",
8051
- "832x1248",
8052
- "1248x832",
8053
- "800x1280",
8054
- "1280x800",
8055
- "720x1280",
8056
- "1280x720",
8057
- "720x1440",
8058
- "1440x720",
8059
- "512x1536",
8060
- "1536x512"
8022
+ var IDEOGRAM_45_ASPECT_RATIOS = [
8023
+ "auto",
8024
+ "source",
8025
+ "1:1",
8026
+ "16:9",
8027
+ "9:16",
8028
+ "4:3",
8029
+ "3:4",
8030
+ "3:2",
8031
+ "2:3",
8032
+ "5:4",
8033
+ "4:5",
8034
+ "8:5",
8035
+ "5:8",
8036
+ "2:1",
8037
+ "1:2",
8038
+ "3:1",
8039
+ "1:3"
8061
8040
  ];
8062
8041
  var ideogram45MaskParam = p.file("mask", "image", {
8063
8042
  label: "Mask",
@@ -8083,15 +8062,22 @@ var IDEOGRAM_45_COUNTS = [1, 2, 3, 4, 5, 6, 7, 8];
8083
8062
  var IDEOGRAM_45_QUALITIES = ["very_low", "low", "medium", "high"];
8084
8063
  var ideogram45Constraints = [
8085
8064
  { when: { imageUrls: { exists: false } }, then: {
8086
- size: { allowed: ["auto", ...IDEOGRAM_45_T2I_SIZES] },
8065
+ aspectRatio: {
8066
+ allowed: IDEOGRAM_45_ASPECT_RATIOS.filter((ar) => ar !== "source"),
8067
+ reason: '"Source" keeps the size of a source image.'
8068
+ },
8087
8069
  mask: { disabled: true, reason: "A mask needs a source image." },
8088
8070
  quality: { allowed: ["low", "medium", "high"], reason: "Very low quality needs a source image." }
8089
8071
  } },
8090
- { when: { imageUrls: { exists: true } }, then: {
8091
- size: { allowed: ["auto", "source"], reason: 'With input images the size is "auto" or the source image size.' }
8092
- } },
8093
8072
  { when: { mask: { exists: true } }, then: {
8094
- size: { disabled: true, reason: "A masked edit keeps the source image size." }
8073
+ aspectRatio: { disabled: true, reason: "A masked edit keeps the source image size." },
8074
+ resolution: { disabled: true, reason: "A masked edit keeps the source image size." }
8075
+ } },
8076
+ { when: { aspectRatio: { is: "auto" } }, then: {
8077
+ resolution: { disabled: true, reason: "Auto picks a 2K size." }
8078
+ } },
8079
+ { when: { aspectRatio: { is: "source" } }, then: {
8080
+ resolution: { disabled: true, reason: "The output keeps the source image size." }
8095
8081
  } }
8096
8082
  ];
8097
8083
  var { MODELS: MODELS26 } = defineModels("ideogram", [
@@ -8112,7 +8098,8 @@ var { MODELS: MODELS26 } = defineModels("ideogram", [
8112
8098
  // With a mask the vendor allows at most 4 images.
8113
8099
  ...params.imageInput(5, "Images", false, "reference", IDEOGRAM_45_IMAGE_BOUNDS),
8114
8100
  ...ideogram45MaskParam,
8115
- ...p.size(["auto", "source", ...IDEOGRAM_45_T2I_SIZES], "auto"),
8101
+ ...params.aspectRatio(IDEOGRAM_45_ASPECT_RATIOS, "auto"),
8102
+ ...params.resolution(["1K", "2K"], "2K"),
8116
8103
  ...ideogram45MagicPromptParam,
8117
8104
  ...p.quality(IDEOGRAM_45_QUALITIES, "high"),
8118
8105
  ...params.count(IDEOGRAM_45_COUNTS, 1),
@@ -8347,22 +8334,23 @@ function assertMaskedImageLimit(model, count, max, what) {
8347
8334
  function invalid2(message) {
8348
8335
  return new ApiError(message, { status: 400, code: "validation_error" });
8349
8336
  }
8350
- function ideogram45Size(size, hasImages, hasMask) {
8351
- if (!size || hasMask) return void 0;
8352
- if (hasImages) return size === "auto" || size === "source" ? size : void 0;
8353
- return size === "source" ? void 0 : size;
8337
+ function ideogram45Shape(input, hasImages, hasMask) {
8338
+ const aspectRatio = input.aspectRatio;
8339
+ if (!aspectRatio || hasMask) return {};
8340
+ if (aspectRatio === "source" && !hasImages) return {};
8341
+ if (aspectRatio === "auto" || aspectRatio === "source") return { aspect_ratio: aspectRatio };
8342
+ return { aspect_ratio: aspectRatio, ...input.resolution ? { resolution: input.resolution } : {} };
8354
8343
  }
8355
8344
  var buildIdeogram45Payload = (input) => {
8356
8345
  const images = input.imageUrls?.length ? input.imageUrls : void 0;
8357
8346
  const mask = images && input.mask ? input.mask : void 0;
8358
8347
  if (mask) assertMaskedImageLimit("Ideogram 4.5", images.length, GENERATE_MAX_IMAGES_WITH_MASK, "images");
8359
- const size = ideogram45Size(input.size, !!images, !!mask);
8360
8348
  if (input.quality === "very_low" && !images) throw invalid2("Ideogram 4.5: very_low quality needs a source image.");
8361
8349
  return {
8362
8350
  prompt: input.prompt,
8363
8351
  ...images ? { images } : {},
8364
8352
  ...mask ? { mask } : {},
8365
- ...size ? { size } : {},
8353
+ ...ideogram45Shape(input, !!images, !!mask),
8366
8354
  ...input.magicPrompt ? { magic_prompt: input.magicPrompt } : {},
8367
8355
  // Vendor default: medium with source images, high without.
8368
8356
  quality: input.quality ?? (images ? "medium" : "high"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "6.22.0",
3
+ "version": "6.22.1",
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",