@ai-sdk/luma 3.0.0-beta.3 → 3.0.0-beta.30
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 +234 -8
- package/README.md +2 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +89 -87
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/luma-image-model.ts +32 -16
- package/src/luma-provider.ts +11 -7
- package/dist/index.d.mts +0 -76
- package/dist/index.mjs +0 -399
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,231 @@
|
|
|
1
1
|
# @ai-sdk/luma
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
8
|
+
- Updated dependencies [9bd6512]
|
|
9
|
+
- Updated dependencies [258c093]
|
|
10
|
+
- Updated dependencies [b6783da]
|
|
11
|
+
- @ai-sdk/provider-utils@5.0.0-beta.29
|
|
12
|
+
- @ai-sdk/provider@4.0.0-beta.14
|
|
13
|
+
|
|
14
|
+
## 3.0.0-beta.29
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
19
|
+
- Updated dependencies [9f0e36c]
|
|
20
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
21
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
22
|
+
|
|
23
|
+
## 3.0.0-beta.28
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [785fe16]
|
|
28
|
+
- Updated dependencies [67df0a0]
|
|
29
|
+
- Updated dependencies [befb78c]
|
|
30
|
+
- Updated dependencies [0458559]
|
|
31
|
+
- Updated dependencies [5852c0a]
|
|
32
|
+
- Updated dependencies [fc92055]
|
|
33
|
+
- @ai-sdk/provider-utils@5.0.0-beta.27
|
|
34
|
+
|
|
35
|
+
## 3.0.0-beta.27
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [2e98477]
|
|
40
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
41
|
+
|
|
42
|
+
## 3.0.0-beta.26
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [eea8d98]
|
|
47
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
48
|
+
|
|
49
|
+
## 3.0.0-beta.25
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- Updated dependencies [f807e45]
|
|
54
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
55
|
+
|
|
56
|
+
## 3.0.0-beta.24
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [350ea38]
|
|
61
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
62
|
+
|
|
63
|
+
## 3.0.0-beta.23
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [083947b]
|
|
68
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
69
|
+
|
|
70
|
+
## 3.0.0-beta.22
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Updated dependencies [add1126]
|
|
75
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
76
|
+
|
|
77
|
+
## 3.0.0-beta.21
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
82
|
+
|
|
83
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
84
|
+
|
|
85
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
86
|
+
|
|
87
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
88
|
+
|
|
89
|
+
- Updated dependencies [b3976a2]
|
|
90
|
+
- Updated dependencies [ff5eba1]
|
|
91
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
92
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
93
|
+
|
|
94
|
+
## 3.0.0-beta.20
|
|
95
|
+
|
|
96
|
+
### Major Changes
|
|
97
|
+
|
|
98
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [ef992f8]
|
|
103
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
104
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
105
|
+
|
|
106
|
+
## 3.0.0-beta.19
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
111
|
+
- Updated dependencies [90e2d8a]
|
|
112
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
113
|
+
|
|
114
|
+
## 3.0.0-beta.18
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- Updated dependencies [3ae1786]
|
|
119
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
120
|
+
|
|
121
|
+
## 3.0.0-beta.17
|
|
122
|
+
|
|
123
|
+
### Patch Changes
|
|
124
|
+
|
|
125
|
+
- Updated dependencies [176466a]
|
|
126
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
127
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
128
|
+
|
|
129
|
+
## 3.0.0-beta.16
|
|
130
|
+
|
|
131
|
+
### Patch Changes
|
|
132
|
+
|
|
133
|
+
- Updated dependencies [e311194]
|
|
134
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
135
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
136
|
+
|
|
137
|
+
## 3.0.0-beta.15
|
|
138
|
+
|
|
139
|
+
### Patch Changes
|
|
140
|
+
|
|
141
|
+
- Updated dependencies [34bd95d]
|
|
142
|
+
- Updated dependencies [008271d]
|
|
143
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
144
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
145
|
+
|
|
146
|
+
## 3.0.0-beta.14
|
|
147
|
+
|
|
148
|
+
### Patch Changes
|
|
149
|
+
|
|
150
|
+
- Updated dependencies [b0c2869]
|
|
151
|
+
- Updated dependencies [7e26e81]
|
|
152
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
153
|
+
|
|
154
|
+
## 3.0.0-beta.13
|
|
155
|
+
|
|
156
|
+
### Patch Changes
|
|
157
|
+
|
|
158
|
+
- Updated dependencies [46d1149]
|
|
159
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
160
|
+
|
|
161
|
+
## 3.0.0-beta.12
|
|
162
|
+
|
|
163
|
+
### Patch Changes
|
|
164
|
+
|
|
165
|
+
- Updated dependencies [6fd51c0]
|
|
166
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
167
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
168
|
+
|
|
169
|
+
## 3.0.0-beta.11
|
|
170
|
+
|
|
171
|
+
### Patch Changes
|
|
172
|
+
|
|
173
|
+
- Updated dependencies [c29a26f]
|
|
174
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
175
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
176
|
+
|
|
177
|
+
## 3.0.0-beta.10
|
|
178
|
+
|
|
179
|
+
### Patch Changes
|
|
180
|
+
|
|
181
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
182
|
+
|
|
183
|
+
## 3.0.0-beta.9
|
|
184
|
+
|
|
185
|
+
### Patch Changes
|
|
186
|
+
|
|
187
|
+
- Updated dependencies [2e17091]
|
|
188
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
189
|
+
|
|
190
|
+
## 3.0.0-beta.8
|
|
191
|
+
|
|
192
|
+
### Patch Changes
|
|
193
|
+
|
|
194
|
+
- Updated dependencies [986c6fd]
|
|
195
|
+
- Updated dependencies [493295c]
|
|
196
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
197
|
+
|
|
198
|
+
## 3.0.0-beta.7
|
|
199
|
+
|
|
200
|
+
### Patch Changes
|
|
201
|
+
|
|
202
|
+
- Updated dependencies [1f509d4]
|
|
203
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
204
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
205
|
+
|
|
206
|
+
## 3.0.0-beta.6
|
|
207
|
+
|
|
208
|
+
### Patch Changes
|
|
209
|
+
|
|
210
|
+
- Updated dependencies [3887c70]
|
|
211
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
212
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
213
|
+
|
|
214
|
+
## 3.0.0-beta.5
|
|
215
|
+
|
|
216
|
+
### Patch Changes
|
|
217
|
+
|
|
218
|
+
- Updated dependencies [776b617]
|
|
219
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
220
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
221
|
+
|
|
222
|
+
## 3.0.0-beta.4
|
|
223
|
+
|
|
224
|
+
### Patch Changes
|
|
225
|
+
|
|
226
|
+
- Updated dependencies [61753c3]
|
|
227
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
228
|
+
|
|
3
229
|
## 3.0.0-beta.3
|
|
4
230
|
|
|
5
231
|
### Patch Changes
|
|
@@ -226,13 +452,13 @@
|
|
|
226
452
|
Before
|
|
227
453
|
|
|
228
454
|
```ts
|
|
229
|
-
model.textEmbeddingModel(
|
|
455
|
+
model.textEmbeddingModel("my-model-id");
|
|
230
456
|
```
|
|
231
457
|
|
|
232
458
|
After
|
|
233
459
|
|
|
234
460
|
```ts
|
|
235
|
-
model.embeddingModel(
|
|
461
|
+
model.embeddingModel("my-model-id");
|
|
236
462
|
```
|
|
237
463
|
|
|
238
464
|
- 95f65c2: chore: use import \* from zod/v4
|
|
@@ -434,13 +660,13 @@
|
|
|
434
660
|
Before
|
|
435
661
|
|
|
436
662
|
```ts
|
|
437
|
-
model.textEmbeddingModel(
|
|
663
|
+
model.textEmbeddingModel("my-model-id");
|
|
438
664
|
```
|
|
439
665
|
|
|
440
666
|
After
|
|
441
667
|
|
|
442
668
|
```ts
|
|
443
|
-
model.embeddingModel(
|
|
669
|
+
model.embeddingModel("my-model-id");
|
|
444
670
|
```
|
|
445
671
|
|
|
446
672
|
- Updated dependencies [8d9e8ad]
|
|
@@ -810,7 +1036,7 @@
|
|
|
810
1036
|
|
|
811
1037
|
```js
|
|
812
1038
|
await generateImage({
|
|
813
|
-
model: luma.image(
|
|
1039
|
+
model: luma.image("photon-flash-1", {
|
|
814
1040
|
maxImagesPerCall: 5,
|
|
815
1041
|
pollIntervalMillis: 500,
|
|
816
1042
|
}),
|
|
@@ -823,7 +1049,7 @@
|
|
|
823
1049
|
|
|
824
1050
|
```js
|
|
825
1051
|
await generateImage({
|
|
826
|
-
model: luma.image(
|
|
1052
|
+
model: luma.image("photon-flash-1"),
|
|
827
1053
|
prompt,
|
|
828
1054
|
n: 10,
|
|
829
1055
|
maxImagesPerCall: 5,
|
|
@@ -1059,7 +1285,7 @@
|
|
|
1059
1285
|
|
|
1060
1286
|
```js
|
|
1061
1287
|
await generateImage({
|
|
1062
|
-
model: luma.image(
|
|
1288
|
+
model: luma.image("photon-flash-1", {
|
|
1063
1289
|
maxImagesPerCall: 5,
|
|
1064
1290
|
pollIntervalMillis: 500,
|
|
1065
1291
|
}),
|
|
@@ -1072,7 +1298,7 @@
|
|
|
1072
1298
|
|
|
1073
1299
|
```js
|
|
1074
1300
|
await generateImage({
|
|
1075
|
-
model: luma.image(
|
|
1301
|
+
model: luma.image("photon-flash-1"),
|
|
1076
1302
|
prompt,
|
|
1077
1303
|
n: 10,
|
|
1078
1304
|
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 {
|
|
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
|
|
28
|
+
interface LumaProvider extends ProviderV4 {
|
|
29
29
|
/**
|
|
30
30
|
* Creates a model for image generation.
|
|
31
31
|
*/
|
|
32
|
-
image(modelId: LumaImageModelId):
|
|
32
|
+
image(modelId: LumaImageModelId): ImageModelV4;
|
|
33
33
|
/**
|
|
34
34
|
* Creates a model for image generation.
|
|
35
35
|
*/
|
|
36
|
-
imageModel(modelId: LumaImageModelId):
|
|
36
|
+
imageModel(modelId: LumaImageModelId): ImageModelV4;
|
|
37
37
|
/**
|
|
38
38
|
* @deprecated Use `embeddingModel` instead.
|
|
39
39
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,41 @@
|
|
|
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
|
-
|
|
31
|
-
|
|
2
|
+
import {
|
|
3
|
+
NoSuchModelError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
loadApiKey,
|
|
7
|
+
withoutTrailingSlash,
|
|
8
|
+
withUserAgentSuffix
|
|
9
|
+
} from "@ai-sdk/provider-utils";
|
|
32
10
|
|
|
33
11
|
// src/luma-image-model.ts
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
12
|
+
import {
|
|
13
|
+
InvalidResponseDataError
|
|
14
|
+
} from "@ai-sdk/provider";
|
|
15
|
+
import {
|
|
16
|
+
combineHeaders,
|
|
17
|
+
createBinaryResponseHandler,
|
|
18
|
+
createJsonResponseHandler,
|
|
19
|
+
createJsonErrorResponseHandler,
|
|
20
|
+
createStatusCodeErrorResponseHandler,
|
|
21
|
+
delay,
|
|
22
|
+
getFromApi,
|
|
23
|
+
postJsonToApi,
|
|
24
|
+
lazySchema,
|
|
25
|
+
parseProviderOptions,
|
|
26
|
+
zodSchema,
|
|
27
|
+
serializeModelOptions,
|
|
28
|
+
WORKFLOW_SERIALIZE,
|
|
29
|
+
WORKFLOW_DESERIALIZE
|
|
30
|
+
} from "@ai-sdk/provider-utils";
|
|
31
|
+
import { z } from "zod/v4";
|
|
37
32
|
var DEFAULT_POLL_INTERVAL_MILLIS = 500;
|
|
38
33
|
var DEFAULT_MAX_POLL_ATTEMPTS = 6e4 / DEFAULT_POLL_INTERVAL_MILLIS;
|
|
39
|
-
var LumaImageModel = class {
|
|
34
|
+
var LumaImageModel = class _LumaImageModel {
|
|
40
35
|
constructor(modelId, config) {
|
|
41
36
|
this.modelId = modelId;
|
|
42
37
|
this.config = config;
|
|
43
|
-
this.specificationVersion = "
|
|
38
|
+
this.specificationVersion = "v4";
|
|
44
39
|
this.maxImagesPerCall = 1;
|
|
45
40
|
this.pollIntervalMillis = DEFAULT_POLL_INTERVAL_MILLIS;
|
|
46
41
|
this.maxPollAttempts = DEFAULT_MAX_POLL_ATTEMPTS;
|
|
@@ -48,9 +43,17 @@ var LumaImageModel = class {
|
|
|
48
43
|
get provider() {
|
|
49
44
|
return this.config.provider;
|
|
50
45
|
}
|
|
46
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
47
|
+
return serializeModelOptions({
|
|
48
|
+
modelId: model.modelId,
|
|
49
|
+
config: model.config
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
53
|
+
return new _LumaImageModel(options.modelId, options.config);
|
|
54
|
+
}
|
|
51
55
|
async doGenerate({
|
|
52
56
|
prompt,
|
|
53
|
-
n,
|
|
54
57
|
size,
|
|
55
58
|
aspectRatio,
|
|
56
59
|
seed,
|
|
@@ -60,7 +63,7 @@ var LumaImageModel = class {
|
|
|
60
63
|
files,
|
|
61
64
|
mask
|
|
62
65
|
}) {
|
|
63
|
-
var _a, _b, _c;
|
|
66
|
+
var _a, _b, _c, _d, _e;
|
|
64
67
|
const warnings = [];
|
|
65
68
|
if (seed != null) {
|
|
66
69
|
warnings.push({
|
|
@@ -76,7 +79,7 @@ var LumaImageModel = class {
|
|
|
76
79
|
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
77
80
|
});
|
|
78
81
|
}
|
|
79
|
-
const lumaOptions = await
|
|
82
|
+
const lumaOptions = await parseProviderOptions({
|
|
80
83
|
provider: "luma",
|
|
81
84
|
providerOptions,
|
|
82
85
|
schema: lumaImageModelOptionsSchema
|
|
@@ -95,8 +98,8 @@ var LumaImageModel = class {
|
|
|
95
98
|
imageConfigs != null ? imageConfigs : []
|
|
96
99
|
);
|
|
97
100
|
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 = (
|
|
99
|
-
const { value: generationResponse, responseHeaders } = await
|
|
101
|
+
const fullHeaders = combineHeaders((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), headers);
|
|
102
|
+
const { value: generationResponse, responseHeaders } = await postJsonToApi({
|
|
100
103
|
url: this.getLumaGenerationsUrl(),
|
|
101
104
|
headers: fullHeaders,
|
|
102
105
|
body: {
|
|
@@ -109,7 +112,7 @@ var LumaImageModel = class {
|
|
|
109
112
|
abortSignal,
|
|
110
113
|
fetch: this.config.fetch,
|
|
111
114
|
failedResponseHandler: this.createLumaErrorHandler(),
|
|
112
|
-
successfulResponseHandler:
|
|
115
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
113
116
|
lumaGenerationResponseSchema
|
|
114
117
|
)
|
|
115
118
|
});
|
|
@@ -139,39 +142,39 @@ var LumaImageModel = class {
|
|
|
139
142
|
const maxPollAttempts = (_a = pollSettings == null ? void 0 : pollSettings.maxPollAttempts) != null ? _a : this.maxPollAttempts;
|
|
140
143
|
const pollIntervalMillis = (_b = pollSettings == null ? void 0 : pollSettings.pollIntervalMillis) != null ? _b : this.pollIntervalMillis;
|
|
141
144
|
for (let i = 0; i < maxPollAttempts; i++) {
|
|
142
|
-
const { value: statusResponse } = await
|
|
145
|
+
const { value: statusResponse } = await getFromApi({
|
|
143
146
|
url,
|
|
144
147
|
headers,
|
|
145
148
|
abortSignal,
|
|
146
149
|
fetch: this.config.fetch,
|
|
147
150
|
failedResponseHandler: this.createLumaErrorHandler(),
|
|
148
|
-
successfulResponseHandler:
|
|
151
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
149
152
|
lumaGenerationResponseSchema
|
|
150
153
|
)
|
|
151
154
|
});
|
|
152
155
|
switch (statusResponse.state) {
|
|
153
156
|
case "completed":
|
|
154
157
|
if (!((_c = statusResponse.assets) == null ? void 0 : _c.image)) {
|
|
155
|
-
throw new
|
|
158
|
+
throw new InvalidResponseDataError({
|
|
156
159
|
data: statusResponse,
|
|
157
160
|
message: `Image generation completed but no image was found.`
|
|
158
161
|
});
|
|
159
162
|
}
|
|
160
163
|
return statusResponse.assets.image;
|
|
161
164
|
case "failed":
|
|
162
|
-
throw new
|
|
165
|
+
throw new InvalidResponseDataError({
|
|
163
166
|
data: statusResponse,
|
|
164
167
|
message: `Image generation failed.`
|
|
165
168
|
});
|
|
166
169
|
}
|
|
167
|
-
await
|
|
170
|
+
await delay(pollIntervalMillis);
|
|
168
171
|
}
|
|
169
172
|
throw new Error(
|
|
170
173
|
`Image generation timed out after ${this.maxPollAttempts} attempts.`
|
|
171
174
|
);
|
|
172
175
|
}
|
|
173
176
|
createLumaErrorHandler() {
|
|
174
|
-
return
|
|
177
|
+
return createJsonErrorResponseHandler({
|
|
175
178
|
errorSchema: lumaErrorSchema,
|
|
176
179
|
errorToMessage: (error) => {
|
|
177
180
|
var _a;
|
|
@@ -271,47 +274,47 @@ var LumaImageModel = class {
|
|
|
271
274
|
return `${this.config.baseURL}/dream-machine/v1/generations/${generationId != null ? generationId : "image"}`;
|
|
272
275
|
}
|
|
273
276
|
async downloadImage(url, abortSignal) {
|
|
274
|
-
const { value: response } = await
|
|
277
|
+
const { value: response } = await getFromApi({
|
|
275
278
|
url,
|
|
276
279
|
// No specific headers should be needed for this request as it's a
|
|
277
280
|
// generated image provided by Luma.
|
|
278
281
|
abortSignal,
|
|
279
|
-
failedResponseHandler:
|
|
280
|
-
successfulResponseHandler:
|
|
282
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
283
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
281
284
|
fetch: this.config.fetch
|
|
282
285
|
});
|
|
283
286
|
return response;
|
|
284
287
|
}
|
|
285
288
|
};
|
|
286
|
-
var lumaGenerationResponseSchema =
|
|
287
|
-
() =>
|
|
288
|
-
|
|
289
|
-
id:
|
|
290
|
-
state:
|
|
291
|
-
failure_reason:
|
|
292
|
-
assets:
|
|
293
|
-
image:
|
|
289
|
+
var lumaGenerationResponseSchema = lazySchema(
|
|
290
|
+
() => zodSchema(
|
|
291
|
+
z.object({
|
|
292
|
+
id: z.string(),
|
|
293
|
+
state: z.enum(["queued", "dreaming", "completed", "failed"]),
|
|
294
|
+
failure_reason: z.string().nullish(),
|
|
295
|
+
assets: z.object({
|
|
296
|
+
image: z.string()
|
|
294
297
|
// URL of the generated image
|
|
295
298
|
}).nullish()
|
|
296
299
|
})
|
|
297
300
|
)
|
|
298
301
|
);
|
|
299
|
-
var lumaErrorSchema =
|
|
300
|
-
detail:
|
|
301
|
-
|
|
302
|
-
type:
|
|
303
|
-
loc:
|
|
304
|
-
msg:
|
|
305
|
-
input:
|
|
306
|
-
ctx:
|
|
307
|
-
expected:
|
|
302
|
+
var lumaErrorSchema = z.object({
|
|
303
|
+
detail: z.array(
|
|
304
|
+
z.object({
|
|
305
|
+
type: z.string(),
|
|
306
|
+
loc: z.array(z.string()),
|
|
307
|
+
msg: z.string(),
|
|
308
|
+
input: z.string(),
|
|
309
|
+
ctx: z.object({
|
|
310
|
+
expected: z.string()
|
|
308
311
|
}).nullish()
|
|
309
312
|
})
|
|
310
313
|
)
|
|
311
314
|
});
|
|
312
|
-
var lumaImageModelOptionsSchema =
|
|
313
|
-
() =>
|
|
314
|
-
|
|
315
|
+
var lumaImageModelOptionsSchema = lazySchema(
|
|
316
|
+
() => zodSchema(
|
|
317
|
+
z.object({
|
|
315
318
|
/**
|
|
316
319
|
* The type of image reference to use when providing input images.
|
|
317
320
|
* - `image`: Guide generation using reference images (up to 4). Default.
|
|
@@ -319,20 +322,20 @@ var lumaImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
|
319
322
|
* - `character`: Create consistent characters from reference images (up to 4).
|
|
320
323
|
* - `modify_image`: Transform a single input image with prompt guidance.
|
|
321
324
|
*/
|
|
322
|
-
referenceType:
|
|
325
|
+
referenceType: z.enum(["image", "style", "character", "modify_image"]).nullish(),
|
|
323
326
|
/**
|
|
324
327
|
* Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
|
|
325
328
|
* Allows setting individual weights for each reference image.
|
|
326
329
|
*/
|
|
327
|
-
images:
|
|
328
|
-
|
|
330
|
+
images: z.array(
|
|
331
|
+
z.object({
|
|
329
332
|
/**
|
|
330
333
|
* The weight of this image's influence on the generation.
|
|
331
334
|
* - For `image`: Higher weight = closer to reference (default: 0.85)
|
|
332
335
|
* - For `style`: Higher weight = stronger style influence (default: 0.8)
|
|
333
336
|
* - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
|
|
334
337
|
*/
|
|
335
|
-
weight:
|
|
338
|
+
weight: z.number().min(0).max(1).nullish(),
|
|
336
339
|
/**
|
|
337
340
|
* The identity name for character references.
|
|
338
341
|
* Used with `character` to specify which identity group the image belongs to.
|
|
@@ -340,32 +343,32 @@ var lumaImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
|
340
343
|
* images with multiple consistent characters.
|
|
341
344
|
* Default: 'identity0'
|
|
342
345
|
*/
|
|
343
|
-
id:
|
|
346
|
+
id: z.string().nullish()
|
|
344
347
|
})
|
|
345
348
|
).nullish(),
|
|
346
349
|
/**
|
|
347
350
|
* Override the polling interval in milliseconds (default 500).
|
|
348
351
|
*/
|
|
349
|
-
pollIntervalMillis:
|
|
352
|
+
pollIntervalMillis: z.number().nullish(),
|
|
350
353
|
/**
|
|
351
354
|
* Override the maximum number of polling attempts (default 120).
|
|
352
355
|
*/
|
|
353
|
-
maxPollAttempts:
|
|
356
|
+
maxPollAttempts: z.number().nullish()
|
|
354
357
|
}).passthrough()
|
|
355
358
|
)
|
|
356
359
|
);
|
|
357
360
|
|
|
358
361
|
// src/version.ts
|
|
359
|
-
var VERSION = true ? "3.0.0-beta.
|
|
362
|
+
var VERSION = true ? "3.0.0-beta.30" : "0.0.0-test";
|
|
360
363
|
|
|
361
364
|
// src/luma-provider.ts
|
|
362
365
|
var defaultBaseURL = "https://api.lumalabs.ai";
|
|
363
366
|
function createLuma(options = {}) {
|
|
364
367
|
var _a;
|
|
365
|
-
const baseURL =
|
|
366
|
-
const getHeaders = () =>
|
|
368
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
369
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
367
370
|
{
|
|
368
|
-
Authorization: `Bearer ${
|
|
371
|
+
Authorization: `Bearer ${loadApiKey({
|
|
369
372
|
apiKey: options.apiKey,
|
|
370
373
|
environmentVariableName: "LUMA_API_KEY",
|
|
371
374
|
description: "Luma"
|
|
@@ -381,17 +384,17 @@ function createLuma(options = {}) {
|
|
|
381
384
|
fetch: options.fetch
|
|
382
385
|
});
|
|
383
386
|
const embeddingModel = (modelId) => {
|
|
384
|
-
throw new
|
|
387
|
+
throw new NoSuchModelError({
|
|
385
388
|
modelId,
|
|
386
389
|
modelType: "embeddingModel"
|
|
387
390
|
});
|
|
388
391
|
};
|
|
389
392
|
return {
|
|
390
|
-
specificationVersion: "
|
|
393
|
+
specificationVersion: "v4",
|
|
391
394
|
image: createImageModel,
|
|
392
395
|
imageModel: createImageModel,
|
|
393
396
|
languageModel: (modelId) => {
|
|
394
|
-
throw new
|
|
397
|
+
throw new NoSuchModelError({
|
|
395
398
|
modelId,
|
|
396
399
|
modelType: "languageModel"
|
|
397
400
|
});
|
|
@@ -401,10 +404,9 @@ function createLuma(options = {}) {
|
|
|
401
404
|
};
|
|
402
405
|
}
|
|
403
406
|
var luma = createLuma();
|
|
404
|
-
|
|
405
|
-
0 && (module.exports = {
|
|
407
|
+
export {
|
|
406
408
|
VERSION,
|
|
407
409
|
createLuma,
|
|
408
410
|
luma
|
|
409
|
-
}
|
|
411
|
+
};
|
|
410
412
|
//# sourceMappingURL=index.js.map
|