@ai-sdk/luma 3.0.0-beta.2 → 3.0.0-beta.20

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/CHANGELOG.md CHANGED
@@ -1,5 +1,148 @@
1
1
  # @ai-sdk/luma
2
2
 
3
+ ## 3.0.0-beta.20
4
+
5
+ ### Major Changes
6
+
7
+ - ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [ef992f8]
12
+ - @ai-sdk/provider@4.0.0-beta.11
13
+ - @ai-sdk/provider-utils@5.0.0-beta.19
14
+
15
+ ## 3.0.0-beta.19
16
+
17
+ ### Patch Changes
18
+
19
+ - 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
20
+ - Updated dependencies [90e2d8a]
21
+ - @ai-sdk/provider-utils@5.0.0-beta.18
22
+
23
+ ## 3.0.0-beta.18
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [3ae1786]
28
+ - @ai-sdk/provider-utils@5.0.0-beta.17
29
+
30
+ ## 3.0.0-beta.17
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [176466a]
35
+ - @ai-sdk/provider@4.0.0-beta.10
36
+ - @ai-sdk/provider-utils@5.0.0-beta.16
37
+
38
+ ## 3.0.0-beta.16
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies [e311194]
43
+ - @ai-sdk/provider@4.0.0-beta.9
44
+ - @ai-sdk/provider-utils@5.0.0-beta.15
45
+
46
+ ## 3.0.0-beta.15
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [34bd95d]
51
+ - Updated dependencies [008271d]
52
+ - @ai-sdk/provider@4.0.0-beta.8
53
+ - @ai-sdk/provider-utils@5.0.0-beta.14
54
+
55
+ ## 3.0.0-beta.14
56
+
57
+ ### Patch Changes
58
+
59
+ - Updated dependencies [b0c2869]
60
+ - Updated dependencies [7e26e81]
61
+ - @ai-sdk/provider-utils@5.0.0-beta.13
62
+
63
+ ## 3.0.0-beta.13
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies [46d1149]
68
+ - @ai-sdk/provider-utils@5.0.0-beta.12
69
+
70
+ ## 3.0.0-beta.12
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies [6fd51c0]
75
+ - @ai-sdk/provider-utils@5.0.0-beta.11
76
+ - @ai-sdk/provider@4.0.0-beta.7
77
+
78
+ ## 3.0.0-beta.11
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [c29a26f]
83
+ - @ai-sdk/provider-utils@5.0.0-beta.10
84
+ - @ai-sdk/provider@4.0.0-beta.6
85
+
86
+ ## 3.0.0-beta.10
87
+
88
+ ### Patch Changes
89
+
90
+ - 38fc777: Add AI Gateway hint to provider READMEs
91
+
92
+ ## 3.0.0-beta.9
93
+
94
+ ### Patch Changes
95
+
96
+ - Updated dependencies [2e17091]
97
+ - @ai-sdk/provider-utils@5.0.0-beta.9
98
+
99
+ ## 3.0.0-beta.8
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies [986c6fd]
104
+ - Updated dependencies [493295c]
105
+ - @ai-sdk/provider-utils@5.0.0-beta.8
106
+
107
+ ## 3.0.0-beta.7
108
+
109
+ ### Patch Changes
110
+
111
+ - Updated dependencies [1f509d4]
112
+ - @ai-sdk/provider-utils@5.0.0-beta.7
113
+ - @ai-sdk/provider@4.0.0-beta.5
114
+
115
+ ## 3.0.0-beta.6
116
+
117
+ ### Patch Changes
118
+
119
+ - Updated dependencies [3887c70]
120
+ - @ai-sdk/provider-utils@5.0.0-beta.6
121
+ - @ai-sdk/provider@4.0.0-beta.4
122
+
123
+ ## 3.0.0-beta.5
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies [776b617]
128
+ - @ai-sdk/provider-utils@5.0.0-beta.5
129
+ - @ai-sdk/provider@4.0.0-beta.3
130
+
131
+ ## 3.0.0-beta.4
132
+
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies [61753c3]
136
+ - @ai-sdk/provider-utils@5.0.0-beta.4
137
+
138
+ ## 3.0.0-beta.3
139
+
140
+ ### Patch Changes
141
+
142
+ - Updated dependencies [f7d4f01]
143
+ - @ai-sdk/provider-utils@5.0.0-beta.3
144
+ - @ai-sdk/provider@4.0.0-beta.2
145
+
3
146
  ## 3.0.0-beta.2
4
147
 
5
148
  ### Patch Changes
@@ -218,13 +361,13 @@
218
361
  Before
219
362
 
220
363
  ```ts
221
- model.textEmbeddingModel('my-model-id');
364
+ model.textEmbeddingModel("my-model-id");
222
365
  ```
223
366
 
224
367
  After
225
368
 
226
369
  ```ts
227
- model.embeddingModel('my-model-id');
370
+ model.embeddingModel("my-model-id");
228
371
  ```
229
372
 
230
373
  - 95f65c2: chore: use import \* from zod/v4
@@ -426,13 +569,13 @@
426
569
  Before
427
570
 
428
571
  ```ts
429
- model.textEmbeddingModel('my-model-id');
572
+ model.textEmbeddingModel("my-model-id");
430
573
  ```
431
574
 
432
575
  After
433
576
 
434
577
  ```ts
435
- model.embeddingModel('my-model-id');
578
+ model.embeddingModel("my-model-id");
436
579
  ```
437
580
 
438
581
  - Updated dependencies [8d9e8ad]
@@ -802,7 +945,7 @@
802
945
 
803
946
  ```js
804
947
  await generateImage({
805
- model: luma.image('photon-flash-1', {
948
+ model: luma.image("photon-flash-1", {
806
949
  maxImagesPerCall: 5,
807
950
  pollIntervalMillis: 500,
808
951
  }),
@@ -815,7 +958,7 @@
815
958
 
816
959
  ```js
817
960
  await generateImage({
818
- model: luma.image('photon-flash-1'),
961
+ model: luma.image("photon-flash-1"),
819
962
  prompt,
820
963
  n: 10,
821
964
  maxImagesPerCall: 5,
@@ -1051,7 +1194,7 @@
1051
1194
 
1052
1195
  ```js
1053
1196
  await generateImage({
1054
- model: luma.image('photon-flash-1', {
1197
+ model: luma.image("photon-flash-1", {
1055
1198
  maxImagesPerCall: 5,
1056
1199
  pollIntervalMillis: 500,
1057
1200
  }),
@@ -1064,7 +1207,7 @@
1064
1207
 
1065
1208
  ```js
1066
1209
  await generateImage({
1067
- model: luma.image('photon-flash-1'),
1210
+ model: luma.image("photon-flash-1"),
1068
1211
  prompt,
1069
1212
  n: 10,
1070
1213
  maxImagesPerCall: 5,
package/README.md CHANGED
@@ -14,6 +14,8 @@ Luma Photon and Photon Flash are groundbreaking image generation models that del
14
14
 
15
15
  For more detailed information about the Luma models and their capabilities, please visit [Luma AI](https://lumalabs.ai/).
16
16
 
17
+ > **Deploying to Vercel?** With Vercel's AI Gateway you can access Luma (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
18
+
17
19
  ## Setup
18
20
 
19
21
  The Luma provider is available in the `@ai-sdk/luma` module. You can install it with:
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ProviderV3, ImageModelV3 } from '@ai-sdk/provider';
1
+ import { ProviderV4, ImageModelV4 } from '@ai-sdk/provider';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
4
4
  import { z } from 'zod/v4';
@@ -25,15 +25,15 @@ interface LumaProviderSettings {
25
25
  */
26
26
  fetch?: FetchFunction;
27
27
  }
28
- interface LumaProvider extends ProviderV3 {
28
+ interface LumaProvider extends ProviderV4 {
29
29
  /**
30
30
  * Creates a model for image generation.
31
31
  */
32
- image(modelId: LumaImageModelId): ImageModelV3;
32
+ image(modelId: LumaImageModelId): ImageModelV4;
33
33
  /**
34
34
  * Creates a model for image generation.
35
35
  */
36
- imageModel(modelId: LumaImageModelId): ImageModelV3;
36
+ imageModel(modelId: LumaImageModelId): ImageModelV4;
37
37
  /**
38
38
  * @deprecated Use `embeddingModel` instead.
39
39
  */
package/dist/index.js CHANGED
@@ -1,46 +1,36 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- VERSION: () => VERSION,
24
- createLuma: () => createLuma,
25
- luma: () => luma
26
- });
27
- module.exports = __toCommonJS(index_exports);
28
-
29
1
  // src/luma-provider.ts
30
- var import_provider2 = require("@ai-sdk/provider");
31
- var import_provider_utils2 = require("@ai-sdk/provider-utils");
2
+ import { NoSuchModelError } from "@ai-sdk/provider";
3
+ import {
4
+ loadApiKey,
5
+ withoutTrailingSlash,
6
+ withUserAgentSuffix
7
+ } from "@ai-sdk/provider-utils";
32
8
 
33
9
  // src/luma-image-model.ts
34
- var import_provider = require("@ai-sdk/provider");
35
- var import_provider_utils = require("@ai-sdk/provider-utils");
36
- var import_v4 = require("zod/v4");
10
+ import {
11
+ InvalidResponseDataError
12
+ } from "@ai-sdk/provider";
13
+ import {
14
+ combineHeaders,
15
+ createBinaryResponseHandler,
16
+ createJsonResponseHandler,
17
+ createJsonErrorResponseHandler,
18
+ createStatusCodeErrorResponseHandler,
19
+ delay,
20
+ getFromApi,
21
+ postJsonToApi,
22
+ lazySchema,
23
+ parseProviderOptions,
24
+ zodSchema
25
+ } from "@ai-sdk/provider-utils";
26
+ import { z } from "zod/v4";
37
27
  var DEFAULT_POLL_INTERVAL_MILLIS = 500;
38
28
  var DEFAULT_MAX_POLL_ATTEMPTS = 6e4 / DEFAULT_POLL_INTERVAL_MILLIS;
39
29
  var LumaImageModel = class {
40
30
  constructor(modelId, config) {
41
31
  this.modelId = modelId;
42
32
  this.config = config;
43
- this.specificationVersion = "v3";
33
+ this.specificationVersion = "v4";
44
34
  this.maxImagesPerCall = 1;
45
35
  this.pollIntervalMillis = DEFAULT_POLL_INTERVAL_MILLIS;
46
36
  this.maxPollAttempts = DEFAULT_MAX_POLL_ATTEMPTS;
@@ -50,7 +40,6 @@ var LumaImageModel = class {
50
40
  }
51
41
  async doGenerate({
52
42
  prompt,
53
- n,
54
43
  size,
55
44
  aspectRatio,
56
45
  seed,
@@ -76,7 +65,7 @@ var LumaImageModel = class {
76
65
  details: "This model does not support the `size` option. Use `aspectRatio` instead."
77
66
  });
78
67
  }
79
- const lumaOptions = await (0, import_provider_utils.parseProviderOptions)({
68
+ const lumaOptions = await parseProviderOptions({
80
69
  provider: "luma",
81
70
  providerOptions,
82
71
  schema: lumaImageModelOptionsSchema
@@ -95,8 +84,8 @@ var LumaImageModel = class {
95
84
  imageConfigs != null ? imageConfigs : []
96
85
  );
97
86
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
98
- const fullHeaders = (0, import_provider_utils.combineHeaders)(this.config.headers(), headers);
99
- const { value: generationResponse, responseHeaders } = await (0, import_provider_utils.postJsonToApi)({
87
+ const fullHeaders = combineHeaders(this.config.headers(), headers);
88
+ const { value: generationResponse, responseHeaders } = await postJsonToApi({
100
89
  url: this.getLumaGenerationsUrl(),
101
90
  headers: fullHeaders,
102
91
  body: {
@@ -109,7 +98,7 @@ var LumaImageModel = class {
109
98
  abortSignal,
110
99
  fetch: this.config.fetch,
111
100
  failedResponseHandler: this.createLumaErrorHandler(),
112
- successfulResponseHandler: (0, import_provider_utils.createJsonResponseHandler)(
101
+ successfulResponseHandler: createJsonResponseHandler(
113
102
  lumaGenerationResponseSchema
114
103
  )
115
104
  });
@@ -139,39 +128,39 @@ var LumaImageModel = class {
139
128
  const maxPollAttempts = (_a = pollSettings == null ? void 0 : pollSettings.maxPollAttempts) != null ? _a : this.maxPollAttempts;
140
129
  const pollIntervalMillis = (_b = pollSettings == null ? void 0 : pollSettings.pollIntervalMillis) != null ? _b : this.pollIntervalMillis;
141
130
  for (let i = 0; i < maxPollAttempts; i++) {
142
- const { value: statusResponse } = await (0, import_provider_utils.getFromApi)({
131
+ const { value: statusResponse } = await getFromApi({
143
132
  url,
144
133
  headers,
145
134
  abortSignal,
146
135
  fetch: this.config.fetch,
147
136
  failedResponseHandler: this.createLumaErrorHandler(),
148
- successfulResponseHandler: (0, import_provider_utils.createJsonResponseHandler)(
137
+ successfulResponseHandler: createJsonResponseHandler(
149
138
  lumaGenerationResponseSchema
150
139
  )
151
140
  });
152
141
  switch (statusResponse.state) {
153
142
  case "completed":
154
143
  if (!((_c = statusResponse.assets) == null ? void 0 : _c.image)) {
155
- throw new import_provider.InvalidResponseDataError({
144
+ throw new InvalidResponseDataError({
156
145
  data: statusResponse,
157
146
  message: `Image generation completed but no image was found.`
158
147
  });
159
148
  }
160
149
  return statusResponse.assets.image;
161
150
  case "failed":
162
- throw new import_provider.InvalidResponseDataError({
151
+ throw new InvalidResponseDataError({
163
152
  data: statusResponse,
164
153
  message: `Image generation failed.`
165
154
  });
166
155
  }
167
- await (0, import_provider_utils.delay)(pollIntervalMillis);
156
+ await delay(pollIntervalMillis);
168
157
  }
169
158
  throw new Error(
170
159
  `Image generation timed out after ${this.maxPollAttempts} attempts.`
171
160
  );
172
161
  }
173
162
  createLumaErrorHandler() {
174
- return (0, import_provider_utils.createJsonErrorResponseHandler)({
163
+ return createJsonErrorResponseHandler({
175
164
  errorSchema: lumaErrorSchema,
176
165
  errorToMessage: (error) => {
177
166
  var _a;
@@ -271,47 +260,47 @@ var LumaImageModel = class {
271
260
  return `${this.config.baseURL}/dream-machine/v1/generations/${generationId != null ? generationId : "image"}`;
272
261
  }
273
262
  async downloadImage(url, abortSignal) {
274
- const { value: response } = await (0, import_provider_utils.getFromApi)({
263
+ const { value: response } = await getFromApi({
275
264
  url,
276
265
  // No specific headers should be needed for this request as it's a
277
266
  // generated image provided by Luma.
278
267
  abortSignal,
279
- failedResponseHandler: (0, import_provider_utils.createStatusCodeErrorResponseHandler)(),
280
- successfulResponseHandler: (0, import_provider_utils.createBinaryResponseHandler)(),
268
+ failedResponseHandler: createStatusCodeErrorResponseHandler(),
269
+ successfulResponseHandler: createBinaryResponseHandler(),
281
270
  fetch: this.config.fetch
282
271
  });
283
272
  return response;
284
273
  }
285
274
  };
286
- var lumaGenerationResponseSchema = (0, import_provider_utils.lazySchema)(
287
- () => (0, import_provider_utils.zodSchema)(
288
- import_v4.z.object({
289
- id: import_v4.z.string(),
290
- state: import_v4.z.enum(["queued", "dreaming", "completed", "failed"]),
291
- failure_reason: import_v4.z.string().nullish(),
292
- assets: import_v4.z.object({
293
- image: import_v4.z.string()
275
+ var lumaGenerationResponseSchema = lazySchema(
276
+ () => zodSchema(
277
+ z.object({
278
+ id: z.string(),
279
+ state: z.enum(["queued", "dreaming", "completed", "failed"]),
280
+ failure_reason: z.string().nullish(),
281
+ assets: z.object({
282
+ image: z.string()
294
283
  // URL of the generated image
295
284
  }).nullish()
296
285
  })
297
286
  )
298
287
  );
299
- var lumaErrorSchema = import_v4.z.object({
300
- detail: import_v4.z.array(
301
- import_v4.z.object({
302
- type: import_v4.z.string(),
303
- loc: import_v4.z.array(import_v4.z.string()),
304
- msg: import_v4.z.string(),
305
- input: import_v4.z.string(),
306
- ctx: import_v4.z.object({
307
- expected: import_v4.z.string()
288
+ var lumaErrorSchema = z.object({
289
+ detail: z.array(
290
+ z.object({
291
+ type: z.string(),
292
+ loc: z.array(z.string()),
293
+ msg: z.string(),
294
+ input: z.string(),
295
+ ctx: z.object({
296
+ expected: z.string()
308
297
  }).nullish()
309
298
  })
310
299
  )
311
300
  });
312
- var lumaImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
313
- () => (0, import_provider_utils.zodSchema)(
314
- import_v4.z.object({
301
+ var lumaImageModelOptionsSchema = lazySchema(
302
+ () => zodSchema(
303
+ z.object({
315
304
  /**
316
305
  * The type of image reference to use when providing input images.
317
306
  * - `image`: Guide generation using reference images (up to 4). Default.
@@ -319,20 +308,20 @@ var lumaImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
319
308
  * - `character`: Create consistent characters from reference images (up to 4).
320
309
  * - `modify_image`: Transform a single input image with prompt guidance.
321
310
  */
322
- referenceType: import_v4.z.enum(["image", "style", "character", "modify_image"]).nullish(),
311
+ referenceType: z.enum(["image", "style", "character", "modify_image"]).nullish(),
323
312
  /**
324
313
  * Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
325
314
  * Allows setting individual weights for each reference image.
326
315
  */
327
- images: import_v4.z.array(
328
- import_v4.z.object({
316
+ images: z.array(
317
+ z.object({
329
318
  /**
330
319
  * The weight of this image's influence on the generation.
331
320
  * - For `image`: Higher weight = closer to reference (default: 0.85)
332
321
  * - For `style`: Higher weight = stronger style influence (default: 0.8)
333
322
  * - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
334
323
  */
335
- weight: import_v4.z.number().min(0).max(1).nullish(),
324
+ weight: z.number().min(0).max(1).nullish(),
336
325
  /**
337
326
  * The identity name for character references.
338
327
  * Used with `character` to specify which identity group the image belongs to.
@@ -340,32 +329,32 @@ var lumaImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
340
329
  * images with multiple consistent characters.
341
330
  * Default: 'identity0'
342
331
  */
343
- id: import_v4.z.string().nullish()
332
+ id: z.string().nullish()
344
333
  })
345
334
  ).nullish(),
346
335
  /**
347
336
  * Override the polling interval in milliseconds (default 500).
348
337
  */
349
- pollIntervalMillis: import_v4.z.number().nullish(),
338
+ pollIntervalMillis: z.number().nullish(),
350
339
  /**
351
340
  * Override the maximum number of polling attempts (default 120).
352
341
  */
353
- maxPollAttempts: import_v4.z.number().nullish()
342
+ maxPollAttempts: z.number().nullish()
354
343
  }).passthrough()
355
344
  )
356
345
  );
357
346
 
358
347
  // src/version.ts
359
- var VERSION = true ? "3.0.0-beta.2" : "0.0.0-test";
348
+ var VERSION = true ? "3.0.0-beta.20" : "0.0.0-test";
360
349
 
361
350
  // src/luma-provider.ts
362
351
  var defaultBaseURL = "https://api.lumalabs.ai";
363
352
  function createLuma(options = {}) {
364
353
  var _a;
365
- const baseURL = (0, import_provider_utils2.withoutTrailingSlash)((_a = options.baseURL) != null ? _a : defaultBaseURL);
366
- const getHeaders = () => (0, import_provider_utils2.withUserAgentSuffix)(
354
+ const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
355
+ const getHeaders = () => withUserAgentSuffix(
367
356
  {
368
- Authorization: `Bearer ${(0, import_provider_utils2.loadApiKey)({
357
+ Authorization: `Bearer ${loadApiKey({
369
358
  apiKey: options.apiKey,
370
359
  environmentVariableName: "LUMA_API_KEY",
371
360
  description: "Luma"
@@ -381,17 +370,17 @@ function createLuma(options = {}) {
381
370
  fetch: options.fetch
382
371
  });
383
372
  const embeddingModel = (modelId) => {
384
- throw new import_provider2.NoSuchModelError({
373
+ throw new NoSuchModelError({
385
374
  modelId,
386
375
  modelType: "embeddingModel"
387
376
  });
388
377
  };
389
378
  return {
390
- specificationVersion: "v3",
379
+ specificationVersion: "v4",
391
380
  image: createImageModel,
392
381
  imageModel: createImageModel,
393
382
  languageModel: (modelId) => {
394
- throw new import_provider2.NoSuchModelError({
383
+ throw new NoSuchModelError({
395
384
  modelId,
396
385
  modelType: "languageModel"
397
386
  });
@@ -401,10 +390,9 @@ function createLuma(options = {}) {
401
390
  };
402
391
  }
403
392
  var luma = createLuma();
404
- // Annotate the CommonJS export names for ESM import in node:
405
- 0 && (module.exports = {
393
+ export {
406
394
  VERSION,
407
395
  createLuma,
408
396
  luma
409
- });
397
+ };
410
398
  //# sourceMappingURL=index.js.map