@picsart/ai-sdk 7.43.0 → 7.46.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/README.md CHANGED
@@ -46,7 +46,7 @@ catalog.search('kling') // search by name/id/provider
46
46
 
47
47
  // Model metadata & params — the `Model` accessor
48
48
  Model('flux-2-pro').name // 'Flux 2 Pro'
49
- Model('flux-2-pro').meta() // mode, provider, badges, addedAt, updatedAt, …
49
+ Model('flux-2-pro').meta() // mode, provider, badges, addedAt, releasedAt, updatedAt, …
50
50
  Model('flux-2-pro').params() // accepted parameters
51
51
  Model('flux-2-pro').params().toSchema() // param schema
52
52
 
@@ -257,6 +257,23 @@ const credits = await ai.getCredits(modelId, { prompt }, { serviceTier: 'priorit
257
257
 
258
258
  Left unset, the option is not sent and the platform applies `auto`.
259
259
 
260
+ ## Config ID
261
+
262
+ `configId` runs a generation under a specific platform config. It is sent as the
263
+ `x-config-id` header on every generation route — `generate()`, `generateText()`,
264
+ `run()` and `submit()` — and the model's workflow loads that config in place of
265
+ its default.
266
+
267
+ ```typescript
268
+ await ai.generate(modelId, { prompt }, { configId: 'my-config-id' });
269
+ ```
270
+
271
+ The price calls (`getCredits()`, `options()`) do not take a `configId`: they quote under the default config.
272
+
273
+ The id must exist for the model being called: a workflow that cannot find it
274
+ fails the request with `config_not_found`. Left unset, no id is sent and the
275
+ default config applies.
276
+
260
277
  ## Text Generation (LLMs)
261
278
 
262
279
  Claude, GPT, Gemini, Kimi, Grok and MiniMax text models are called with `generateText()`. Single-shot:
@@ -273,6 +273,7 @@ export type ModelInputById = {
273
273
  "seedream-5.5": { resolution?: "1K" | "1.5K" | "2K"; prompt: string; aspectRatio?: "1:1" | "4:3" | "3:4" | "16:9" | "9:16" | "3:2" | "2:3" | "21:9"; imageUrls?: string[]; negativePrompt?: string; background?: "auto" | "transparent" | "opaque"; };
274
274
  "gpt-image-2.6-flare": { prompt: string; aspectRatio?: "1:1" | "3:2" | "2:3" | "16:9" | "9:16" | "4:3" | "3:4" | "auto"; resolution?: "1K" | "2K" | "4K"; size?: string; quality?: "max" | "xhigh" | "high" | "medium" | "low"; complexity?: "high" | "medium" | "low"; background?: "opaque" | "transparent" | "auto"; outputFormat?: "png" | "jpeg" | "webp" | "gif" | "svg"; frameCount?: number; frameDurationMs?: number; svgAuthorModel?: "gpt-6.1-sol" | "gpt-6.1-terra" | "gpt-6-astra" | "gpt-6-sol" | "gpt-6-luna"; svgReasoningEffort?: "auto" | "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"; count?: 1 | 2 | 4 | 6 | 8 | 10; imageUrls?: string[]; markupUrl?: string; maskUrl?: string; };
275
275
  "topaz-upscale-image": { imageUrls: [string, ...string[]]; model?: "Standard V2" | "Standard MAX" | "Low Resolution V2" | "High Fidelity V2" | "CGI" | "Text Refine" | "Redefine" | "Recovery" | "Recovery V2" | "Wonder" | "Wonder 3"; };
276
+ "topaz-upscale-image-generative": { imageUrls: [string, ...string[]]; model?: "Wonder 4" | "Wonder 3.5" | "Wonder 3" | "Wonder 2" | "Wonder" | "Recover 3" | "Standard MAX" | "Redefine" | "Recovery V2" | "Recovery"; };
276
277
  "topaz-upscale-video": { videoUrl: string; 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"; };
277
278
  "typesafe-evaluate": { state: string; imageUrls?: string[]; questions: Record<string, { type: "noul" | "choice" | "score" | "box"; instructions: unknown } & Record<string, unknown>>; };
278
279
  "veed-fabric-v1": { prompt?: string; resolution?: "480p" | "720p"; imageUrls: [string, ...string[]]; audioUrl: string; };
package/index.d.ts CHANGED
@@ -8,6 +8,12 @@ interface WorkflowSubmitRequest<TPayload = Record<string, unknown>> {
8
8
  workflow: string;
9
9
  payload: TPayload;
10
10
  signal?: AbortSignal;
11
+ /**
12
+ * Config id to run the workflow under — the caller's `configId` option. The
13
+ * built-in transport sends it as the `x-config-id` header; unset, the
14
+ * workflow's default config applies.
15
+ */
16
+ configId?: string;
11
17
  }
12
18
  interface WorkflowJobHandle {
13
19
  workflow: string;
@@ -439,6 +445,8 @@ interface ModelMeta {
439
445
  readonly provider: ProviderInfo;
440
446
  /** ISO YYYY-MM-DD date the model was added to the catalog, or null if unknown. */
441
447
  readonly addedAt: string | null;
448
+ /** ISO YYYY-MM-DD date the model went into full release at Picsart, or null while it is in preview. */
449
+ readonly releasedAt: string | null;
442
450
  /** ISO YYYY-MM-DD date the model definition was last changed, or null if unknown. */
443
451
  readonly updatedAt: string | null;
444
452
  /** Release / availability tier. Absent on the definition ⇒ `'production'`. */
@@ -740,6 +748,8 @@ interface ModelDefinition {
740
748
  badge?: BadgeType[];
741
749
  /** ISO YYYY-MM-DD date the model was added. The 'new' badge is derived from this — see core/badges.ts. */
742
750
  addedAt?: string;
751
+ /** ISO YYYY-MM-DD date the model went into full release at Picsart — tells how new it is. Absent while in preview. */
752
+ releasedAt?: string;
743
753
  /** ISO YYYY-MM-DD date the model definition was last changed. Absent when unknown. */
744
754
  updatedAt?: string;
745
755
  /**
@@ -1421,6 +1431,14 @@ interface GenerateOptions {
1421
1431
  * `generateText()` and `submit()`.
1422
1432
  */
1423
1433
  serviceTier?: ServiceTier;
1434
+ /**
1435
+ * Config id to run this generation under, sent as the `x-config-id` header.
1436
+ * The model's workflow loads the config with this id in place of its
1437
+ * default, so the id must exist for the model being called. Unset, no id is
1438
+ * sent and the default config applies. Applies to `run()`, `generate()`,
1439
+ * `generateText()` and `submit()`.
1440
+ */
1441
+ configId?: string;
1424
1442
  /**
1425
1443
  * App identity stamped onto the saved generation (appId/appType).
1426
1444
  * TODO(backend-autosave): temporary — remove once the backend stamps these.
@@ -1606,6 +1624,8 @@ interface CatalogModel {
1606
1624
  features?: ModelFeature[];
1607
1625
  release?: ReleaseTag;
1608
1626
  addedAt?: string;
1627
+ /** The server sends `null` while the model is still in preview (not yet fully released). */
1628
+ releasedAt?: string | null;
1609
1629
  /** The server sends `null` for a model that has never been changed since it was added. */
1610
1630
  updatedAt?: string | null;
1611
1631
  estimatedTime?: number | Record<string, number>;
package/index.js CHANGED
@@ -669,6 +669,7 @@ function toModelDefinition(wire) {
669
669
  if (wire.badges !== void 0) def.badge = wire.badges;
670
670
  if (wire.release !== void 0) def.release = wire.release;
671
671
  if (wire.addedAt !== void 0) def.addedAt = wire.addedAt;
672
+ if (wire.releasedAt != null) def.releasedAt = wire.releasedAt;
672
673
  if (wire.updatedAt != null) def.updatedAt = wire.updatedAt;
673
674
  if (wire.estimatedTime !== void 0) def.estimatedTime = wire.estimatedTime;
674
675
  if (wire.deprecated !== void 0) def.deprecated = wire.deprecated;
@@ -1454,6 +1455,7 @@ var ModelMetaImpl = class {
1454
1455
  badges;
1455
1456
  provider;
1456
1457
  addedAt;
1458
+ releasedAt;
1457
1459
  updatedAt;
1458
1460
  release;
1459
1461
  constructor(def) {
@@ -1470,6 +1472,7 @@ var ModelMetaImpl = class {
1470
1472
  label: def.providerLabel
1471
1473
  };
1472
1474
  this.addedAt = def.addedAt ?? null;
1475
+ this.releasedAt = def.releasedAt ?? null;
1473
1476
  this.updatedAt = def.updatedAt ?? null;
1474
1477
  }
1475
1478
  };
@@ -2617,7 +2620,7 @@ function toApiError(err, workflow, id) {
2617
2620
 
2618
2621
  // package.json
2619
2622
  var package_default = {
2620
- version: "7.43.0"};
2623
+ version: "7.46.0"};
2621
2624
 
2622
2625
  // src/client/transport.ts
2623
2626
  var GATEWAY_HEADERS = {
@@ -2650,6 +2653,10 @@ function maybeFetch(config) {
2650
2653
  }
2651
2654
  return null;
2652
2655
  }
2656
+ var CONFIG_ID_HEADER = "x-config-id";
2657
+ function configIdHeaders(configId) {
2658
+ return configId ? { [CONFIG_ID_HEADER]: configId } : void 0;
2659
+ }
2653
2660
  function createWorkflowsClient(apiUrl, authedFetch) {
2654
2661
  return new WorkflowsClient_default({
2655
2662
  baseUrl: apiUrl,
@@ -2681,7 +2688,8 @@ function buildTransport(wc) {
2681
2688
  try {
2682
2689
  const res = await wc.run(request.workflow, request.payload, {
2683
2690
  mode: ExecutionMode.SYNC,
2684
- abortSignal: request.signal
2691
+ abortSignal: request.signal,
2692
+ headers: configIdHeaders(request.configId)
2685
2693
  });
2686
2694
  return asResult(res);
2687
2695
  } catch (err) {
@@ -2690,7 +2698,10 @@ function buildTransport(wc) {
2690
2698
  },
2691
2699
  async submit(request) {
2692
2700
  try {
2693
- const id = await wc.submit(request.workflow, request.payload, { abortSignal: request.signal });
2701
+ const id = await wc.submit(request.workflow, request.payload, {
2702
+ abortSignal: request.signal,
2703
+ headers: configIdHeaders(request.configId)
2704
+ });
2694
2705
  if (!id) {
2695
2706
  throw new ApiError("No task id in response", { status: 502, code: "invalid_response" });
2696
2707
  }
@@ -3666,12 +3677,12 @@ function createClient(config) {
3666
3677
  if (!transport.submit) throw unsupportedTransport("submit");
3667
3678
  if (!transport.poll) throw unsupportedTransport("polling");
3668
3679
  }
3669
- async function submitJob(workflow, payload, signal) {
3680
+ async function submitJob(workflow, payload, signal, configId) {
3670
3681
  if (signal?.aborted) {
3671
3682
  throw new ApiError("Operation aborted", { status: 499, code: "aborted" });
3672
3683
  }
3673
3684
  if (!transport.submit) throw unsupportedTransport("submit");
3674
- const id = await transport.submit({ workflow, payload, signal });
3685
+ const id = await transport.submit({ workflow, payload, signal, configId });
3675
3686
  if (!id) {
3676
3687
  throw new ApiError("No task id in response", { status: 502, code: "invalid_response" });
3677
3688
  }
@@ -3710,13 +3721,14 @@ function createClient(config) {
3710
3721
  }
3711
3722
  async function executeDynamic(command, options) {
3712
3723
  const signal = options?.signal;
3724
+ const configId = options?.configId;
3713
3725
  const payload = command;
3714
3726
  try {
3715
3727
  if (!supportsAsync) {
3716
- const res2 = await transport.execute({ workflow: MODELS_WORKFLOW, payload, signal });
3728
+ const res2 = await transport.execute({ workflow: MODELS_WORKFLOW, payload, signal, configId });
3717
3729
  return toCompletedStatus({ workflow: MODELS_WORKFLOW, id: "" }, res2.result, res2.raw ?? res2.result, res2.usage);
3718
3730
  }
3719
- const id = await submitJob(MODELS_WORKFLOW, payload, signal);
3731
+ const id = await submitJob(MODELS_WORKFLOW, payload, signal, configId);
3720
3732
  const res = await pollJob({ workflow: MODELS_WORKFLOW, id }, pollOptionsFor(options));
3721
3733
  return asCompleted({ workflow: MODELS_WORKFLOW, id }, res);
3722
3734
  } catch (err) {
@@ -3880,7 +3892,7 @@ function createClient(config) {
3880
3892
  inputsNormalization: options?.inputsNormalization
3881
3893
  }, resolveServiceTier(options));
3882
3894
  try {
3883
- return await submitJob(MODELS_WORKFLOW, command, options?.signal);
3895
+ return await submitJob(MODELS_WORKFLOW, command, options?.signal, options?.configId);
3884
3896
  } catch (err) {
3885
3897
  throw toApiError2(err, options?.signal);
3886
3898
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picsart/ai-sdk",
3
- "version": "7.43.0",
3
+ "version": "7.46.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",