@ai-sdk/luma 3.0.0-beta.2 → 3.0.0-beta.21
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 +168 -8
- package/README.md +2 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +87 -87
- package/dist/index.js.map +1 -1
- package/package.json +7 -9
- package/src/luma-image-model.ts +30 -14
- package/src/luma-provider.ts +5 -5
- 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,165 @@
|
|
|
1
1
|
# @ai-sdk/luma
|
|
2
2
|
|
|
3
|
+
## 3.0.0-beta.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
8
|
+
|
|
9
|
+
**`@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.
|
|
10
|
+
|
|
11
|
+
**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.
|
|
12
|
+
|
|
13
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [b3976a2]
|
|
16
|
+
- Updated dependencies [ff5eba1]
|
|
17
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
18
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
19
|
+
|
|
20
|
+
## 3.0.0-beta.20
|
|
21
|
+
|
|
22
|
+
### Major Changes
|
|
23
|
+
|
|
24
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [ef992f8]
|
|
29
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
30
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
31
|
+
|
|
32
|
+
## 3.0.0-beta.19
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
37
|
+
- Updated dependencies [90e2d8a]
|
|
38
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
39
|
+
|
|
40
|
+
## 3.0.0-beta.18
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [3ae1786]
|
|
45
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
46
|
+
|
|
47
|
+
## 3.0.0-beta.17
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [176466a]
|
|
52
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
53
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
54
|
+
|
|
55
|
+
## 3.0.0-beta.16
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [e311194]
|
|
60
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
61
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
62
|
+
|
|
63
|
+
## 3.0.0-beta.15
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [34bd95d]
|
|
68
|
+
- Updated dependencies [008271d]
|
|
69
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
70
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
71
|
+
|
|
72
|
+
## 3.0.0-beta.14
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies [b0c2869]
|
|
77
|
+
- Updated dependencies [7e26e81]
|
|
78
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
79
|
+
|
|
80
|
+
## 3.0.0-beta.13
|
|
81
|
+
|
|
82
|
+
### Patch Changes
|
|
83
|
+
|
|
84
|
+
- Updated dependencies [46d1149]
|
|
85
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
86
|
+
|
|
87
|
+
## 3.0.0-beta.12
|
|
88
|
+
|
|
89
|
+
### Patch Changes
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [6fd51c0]
|
|
92
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
93
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
94
|
+
|
|
95
|
+
## 3.0.0-beta.11
|
|
96
|
+
|
|
97
|
+
### Patch Changes
|
|
98
|
+
|
|
99
|
+
- Updated dependencies [c29a26f]
|
|
100
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
101
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
102
|
+
|
|
103
|
+
## 3.0.0-beta.10
|
|
104
|
+
|
|
105
|
+
### Patch Changes
|
|
106
|
+
|
|
107
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
108
|
+
|
|
109
|
+
## 3.0.0-beta.9
|
|
110
|
+
|
|
111
|
+
### Patch Changes
|
|
112
|
+
|
|
113
|
+
- Updated dependencies [2e17091]
|
|
114
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
115
|
+
|
|
116
|
+
## 3.0.0-beta.8
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- Updated dependencies [986c6fd]
|
|
121
|
+
- Updated dependencies [493295c]
|
|
122
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
123
|
+
|
|
124
|
+
## 3.0.0-beta.7
|
|
125
|
+
|
|
126
|
+
### Patch Changes
|
|
127
|
+
|
|
128
|
+
- Updated dependencies [1f509d4]
|
|
129
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
130
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
131
|
+
|
|
132
|
+
## 3.0.0-beta.6
|
|
133
|
+
|
|
134
|
+
### Patch Changes
|
|
135
|
+
|
|
136
|
+
- Updated dependencies [3887c70]
|
|
137
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
138
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
139
|
+
|
|
140
|
+
## 3.0.0-beta.5
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- Updated dependencies [776b617]
|
|
145
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
146
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
147
|
+
|
|
148
|
+
## 3.0.0-beta.4
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- Updated dependencies [61753c3]
|
|
153
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
154
|
+
|
|
155
|
+
## 3.0.0-beta.3
|
|
156
|
+
|
|
157
|
+
### Patch Changes
|
|
158
|
+
|
|
159
|
+
- Updated dependencies [f7d4f01]
|
|
160
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
161
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
162
|
+
|
|
3
163
|
## 3.0.0-beta.2
|
|
4
164
|
|
|
5
165
|
### Patch Changes
|
|
@@ -218,13 +378,13 @@
|
|
|
218
378
|
Before
|
|
219
379
|
|
|
220
380
|
```ts
|
|
221
|
-
model.textEmbeddingModel(
|
|
381
|
+
model.textEmbeddingModel("my-model-id");
|
|
222
382
|
```
|
|
223
383
|
|
|
224
384
|
After
|
|
225
385
|
|
|
226
386
|
```ts
|
|
227
|
-
model.embeddingModel(
|
|
387
|
+
model.embeddingModel("my-model-id");
|
|
228
388
|
```
|
|
229
389
|
|
|
230
390
|
- 95f65c2: chore: use import \* from zod/v4
|
|
@@ -426,13 +586,13 @@
|
|
|
426
586
|
Before
|
|
427
587
|
|
|
428
588
|
```ts
|
|
429
|
-
model.textEmbeddingModel(
|
|
589
|
+
model.textEmbeddingModel("my-model-id");
|
|
430
590
|
```
|
|
431
591
|
|
|
432
592
|
After
|
|
433
593
|
|
|
434
594
|
```ts
|
|
435
|
-
model.embeddingModel(
|
|
595
|
+
model.embeddingModel("my-model-id");
|
|
436
596
|
```
|
|
437
597
|
|
|
438
598
|
- Updated dependencies [8d9e8ad]
|
|
@@ -802,7 +962,7 @@
|
|
|
802
962
|
|
|
803
963
|
```js
|
|
804
964
|
await generateImage({
|
|
805
|
-
model: luma.image(
|
|
965
|
+
model: luma.image("photon-flash-1", {
|
|
806
966
|
maxImagesPerCall: 5,
|
|
807
967
|
pollIntervalMillis: 500,
|
|
808
968
|
}),
|
|
@@ -815,7 +975,7 @@
|
|
|
815
975
|
|
|
816
976
|
```js
|
|
817
977
|
await generateImage({
|
|
818
|
-
model: luma.image(
|
|
978
|
+
model: luma.image("photon-flash-1"),
|
|
819
979
|
prompt,
|
|
820
980
|
n: 10,
|
|
821
981
|
maxImagesPerCall: 5,
|
|
@@ -1051,7 +1211,7 @@
|
|
|
1051
1211
|
|
|
1052
1212
|
```js
|
|
1053
1213
|
await generateImage({
|
|
1054
|
-
model: luma.image(
|
|
1214
|
+
model: luma.image("photon-flash-1", {
|
|
1055
1215
|
maxImagesPerCall: 5,
|
|
1056
1216
|
pollIntervalMillis: 500,
|
|
1057
1217
|
}),
|
|
@@ -1064,7 +1224,7 @@
|
|
|
1064
1224
|
|
|
1065
1225
|
```js
|
|
1066
1226
|
await generateImage({
|
|
1067
|
-
model: luma.image(
|
|
1227
|
+
model: luma.image("photon-flash-1"),
|
|
1068
1228
|
prompt,
|
|
1069
1229
|
n: 10,
|
|
1070
1230
|
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,39 @@
|
|
|
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 { 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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
+
serializeModelOptions,
|
|
26
|
+
WORKFLOW_SERIALIZE,
|
|
27
|
+
WORKFLOW_DESERIALIZE
|
|
28
|
+
} from "@ai-sdk/provider-utils";
|
|
29
|
+
import { z } from "zod/v4";
|
|
37
30
|
var DEFAULT_POLL_INTERVAL_MILLIS = 500;
|
|
38
31
|
var DEFAULT_MAX_POLL_ATTEMPTS = 6e4 / DEFAULT_POLL_INTERVAL_MILLIS;
|
|
39
|
-
var LumaImageModel = class {
|
|
32
|
+
var LumaImageModel = class _LumaImageModel {
|
|
40
33
|
constructor(modelId, config) {
|
|
41
34
|
this.modelId = modelId;
|
|
42
35
|
this.config = config;
|
|
43
|
-
this.specificationVersion = "
|
|
36
|
+
this.specificationVersion = "v4";
|
|
44
37
|
this.maxImagesPerCall = 1;
|
|
45
38
|
this.pollIntervalMillis = DEFAULT_POLL_INTERVAL_MILLIS;
|
|
46
39
|
this.maxPollAttempts = DEFAULT_MAX_POLL_ATTEMPTS;
|
|
@@ -48,9 +41,17 @@ var LumaImageModel = class {
|
|
|
48
41
|
get provider() {
|
|
49
42
|
return this.config.provider;
|
|
50
43
|
}
|
|
44
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
45
|
+
return serializeModelOptions({
|
|
46
|
+
modelId: model.modelId,
|
|
47
|
+
config: model.config
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
51
|
+
return new _LumaImageModel(options.modelId, options.config);
|
|
52
|
+
}
|
|
51
53
|
async doGenerate({
|
|
52
54
|
prompt,
|
|
53
|
-
n,
|
|
54
55
|
size,
|
|
55
56
|
aspectRatio,
|
|
56
57
|
seed,
|
|
@@ -60,7 +61,7 @@ var LumaImageModel = class {
|
|
|
60
61
|
files,
|
|
61
62
|
mask
|
|
62
63
|
}) {
|
|
63
|
-
var _a, _b, _c;
|
|
64
|
+
var _a, _b, _c, _d, _e;
|
|
64
65
|
const warnings = [];
|
|
65
66
|
if (seed != null) {
|
|
66
67
|
warnings.push({
|
|
@@ -76,7 +77,7 @@ var LumaImageModel = class {
|
|
|
76
77
|
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
77
78
|
});
|
|
78
79
|
}
|
|
79
|
-
const lumaOptions = await
|
|
80
|
+
const lumaOptions = await parseProviderOptions({
|
|
80
81
|
provider: "luma",
|
|
81
82
|
providerOptions,
|
|
82
83
|
schema: lumaImageModelOptionsSchema
|
|
@@ -95,8 +96,8 @@ var LumaImageModel = class {
|
|
|
95
96
|
imageConfigs != null ? imageConfigs : []
|
|
96
97
|
);
|
|
97
98
|
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
|
|
99
|
+
const fullHeaders = combineHeaders((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), headers);
|
|
100
|
+
const { value: generationResponse, responseHeaders } = await postJsonToApi({
|
|
100
101
|
url: this.getLumaGenerationsUrl(),
|
|
101
102
|
headers: fullHeaders,
|
|
102
103
|
body: {
|
|
@@ -109,7 +110,7 @@ var LumaImageModel = class {
|
|
|
109
110
|
abortSignal,
|
|
110
111
|
fetch: this.config.fetch,
|
|
111
112
|
failedResponseHandler: this.createLumaErrorHandler(),
|
|
112
|
-
successfulResponseHandler:
|
|
113
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
113
114
|
lumaGenerationResponseSchema
|
|
114
115
|
)
|
|
115
116
|
});
|
|
@@ -139,39 +140,39 @@ var LumaImageModel = class {
|
|
|
139
140
|
const maxPollAttempts = (_a = pollSettings == null ? void 0 : pollSettings.maxPollAttempts) != null ? _a : this.maxPollAttempts;
|
|
140
141
|
const pollIntervalMillis = (_b = pollSettings == null ? void 0 : pollSettings.pollIntervalMillis) != null ? _b : this.pollIntervalMillis;
|
|
141
142
|
for (let i = 0; i < maxPollAttempts; i++) {
|
|
142
|
-
const { value: statusResponse } = await
|
|
143
|
+
const { value: statusResponse } = await getFromApi({
|
|
143
144
|
url,
|
|
144
145
|
headers,
|
|
145
146
|
abortSignal,
|
|
146
147
|
fetch: this.config.fetch,
|
|
147
148
|
failedResponseHandler: this.createLumaErrorHandler(),
|
|
148
|
-
successfulResponseHandler:
|
|
149
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
149
150
|
lumaGenerationResponseSchema
|
|
150
151
|
)
|
|
151
152
|
});
|
|
152
153
|
switch (statusResponse.state) {
|
|
153
154
|
case "completed":
|
|
154
155
|
if (!((_c = statusResponse.assets) == null ? void 0 : _c.image)) {
|
|
155
|
-
throw new
|
|
156
|
+
throw new InvalidResponseDataError({
|
|
156
157
|
data: statusResponse,
|
|
157
158
|
message: `Image generation completed but no image was found.`
|
|
158
159
|
});
|
|
159
160
|
}
|
|
160
161
|
return statusResponse.assets.image;
|
|
161
162
|
case "failed":
|
|
162
|
-
throw new
|
|
163
|
+
throw new InvalidResponseDataError({
|
|
163
164
|
data: statusResponse,
|
|
164
165
|
message: `Image generation failed.`
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
|
-
await
|
|
168
|
+
await delay(pollIntervalMillis);
|
|
168
169
|
}
|
|
169
170
|
throw new Error(
|
|
170
171
|
`Image generation timed out after ${this.maxPollAttempts} attempts.`
|
|
171
172
|
);
|
|
172
173
|
}
|
|
173
174
|
createLumaErrorHandler() {
|
|
174
|
-
return
|
|
175
|
+
return createJsonErrorResponseHandler({
|
|
175
176
|
errorSchema: lumaErrorSchema,
|
|
176
177
|
errorToMessage: (error) => {
|
|
177
178
|
var _a;
|
|
@@ -271,47 +272,47 @@ var LumaImageModel = class {
|
|
|
271
272
|
return `${this.config.baseURL}/dream-machine/v1/generations/${generationId != null ? generationId : "image"}`;
|
|
272
273
|
}
|
|
273
274
|
async downloadImage(url, abortSignal) {
|
|
274
|
-
const { value: response } = await
|
|
275
|
+
const { value: response } = await getFromApi({
|
|
275
276
|
url,
|
|
276
277
|
// No specific headers should be needed for this request as it's a
|
|
277
278
|
// generated image provided by Luma.
|
|
278
279
|
abortSignal,
|
|
279
|
-
failedResponseHandler:
|
|
280
|
-
successfulResponseHandler:
|
|
280
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
281
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
281
282
|
fetch: this.config.fetch
|
|
282
283
|
});
|
|
283
284
|
return response;
|
|
284
285
|
}
|
|
285
286
|
};
|
|
286
|
-
var lumaGenerationResponseSchema =
|
|
287
|
-
() =>
|
|
288
|
-
|
|
289
|
-
id:
|
|
290
|
-
state:
|
|
291
|
-
failure_reason:
|
|
292
|
-
assets:
|
|
293
|
-
image:
|
|
287
|
+
var lumaGenerationResponseSchema = lazySchema(
|
|
288
|
+
() => zodSchema(
|
|
289
|
+
z.object({
|
|
290
|
+
id: z.string(),
|
|
291
|
+
state: z.enum(["queued", "dreaming", "completed", "failed"]),
|
|
292
|
+
failure_reason: z.string().nullish(),
|
|
293
|
+
assets: z.object({
|
|
294
|
+
image: z.string()
|
|
294
295
|
// URL of the generated image
|
|
295
296
|
}).nullish()
|
|
296
297
|
})
|
|
297
298
|
)
|
|
298
299
|
);
|
|
299
|
-
var lumaErrorSchema =
|
|
300
|
-
detail:
|
|
301
|
-
|
|
302
|
-
type:
|
|
303
|
-
loc:
|
|
304
|
-
msg:
|
|
305
|
-
input:
|
|
306
|
-
ctx:
|
|
307
|
-
expected:
|
|
300
|
+
var lumaErrorSchema = z.object({
|
|
301
|
+
detail: z.array(
|
|
302
|
+
z.object({
|
|
303
|
+
type: z.string(),
|
|
304
|
+
loc: z.array(z.string()),
|
|
305
|
+
msg: z.string(),
|
|
306
|
+
input: z.string(),
|
|
307
|
+
ctx: z.object({
|
|
308
|
+
expected: z.string()
|
|
308
309
|
}).nullish()
|
|
309
310
|
})
|
|
310
311
|
)
|
|
311
312
|
});
|
|
312
|
-
var lumaImageModelOptionsSchema =
|
|
313
|
-
() =>
|
|
314
|
-
|
|
313
|
+
var lumaImageModelOptionsSchema = lazySchema(
|
|
314
|
+
() => zodSchema(
|
|
315
|
+
z.object({
|
|
315
316
|
/**
|
|
316
317
|
* The type of image reference to use when providing input images.
|
|
317
318
|
* - `image`: Guide generation using reference images (up to 4). Default.
|
|
@@ -319,20 +320,20 @@ var lumaImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
|
319
320
|
* - `character`: Create consistent characters from reference images (up to 4).
|
|
320
321
|
* - `modify_image`: Transform a single input image with prompt guidance.
|
|
321
322
|
*/
|
|
322
|
-
referenceType:
|
|
323
|
+
referenceType: z.enum(["image", "style", "character", "modify_image"]).nullish(),
|
|
323
324
|
/**
|
|
324
325
|
* Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
|
|
325
326
|
* Allows setting individual weights for each reference image.
|
|
326
327
|
*/
|
|
327
|
-
images:
|
|
328
|
-
|
|
328
|
+
images: z.array(
|
|
329
|
+
z.object({
|
|
329
330
|
/**
|
|
330
331
|
* The weight of this image's influence on the generation.
|
|
331
332
|
* - For `image`: Higher weight = closer to reference (default: 0.85)
|
|
332
333
|
* - For `style`: Higher weight = stronger style influence (default: 0.8)
|
|
333
334
|
* - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
|
|
334
335
|
*/
|
|
335
|
-
weight:
|
|
336
|
+
weight: z.number().min(0).max(1).nullish(),
|
|
336
337
|
/**
|
|
337
338
|
* The identity name for character references.
|
|
338
339
|
* Used with `character` to specify which identity group the image belongs to.
|
|
@@ -340,32 +341,32 @@ var lumaImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
|
340
341
|
* images with multiple consistent characters.
|
|
341
342
|
* Default: 'identity0'
|
|
342
343
|
*/
|
|
343
|
-
id:
|
|
344
|
+
id: z.string().nullish()
|
|
344
345
|
})
|
|
345
346
|
).nullish(),
|
|
346
347
|
/**
|
|
347
348
|
* Override the polling interval in milliseconds (default 500).
|
|
348
349
|
*/
|
|
349
|
-
pollIntervalMillis:
|
|
350
|
+
pollIntervalMillis: z.number().nullish(),
|
|
350
351
|
/**
|
|
351
352
|
* Override the maximum number of polling attempts (default 120).
|
|
352
353
|
*/
|
|
353
|
-
maxPollAttempts:
|
|
354
|
+
maxPollAttempts: z.number().nullish()
|
|
354
355
|
}).passthrough()
|
|
355
356
|
)
|
|
356
357
|
);
|
|
357
358
|
|
|
358
359
|
// src/version.ts
|
|
359
|
-
var VERSION = true ? "3.0.0-beta.
|
|
360
|
+
var VERSION = true ? "3.0.0-beta.21" : "0.0.0-test";
|
|
360
361
|
|
|
361
362
|
// src/luma-provider.ts
|
|
362
363
|
var defaultBaseURL = "https://api.lumalabs.ai";
|
|
363
364
|
function createLuma(options = {}) {
|
|
364
365
|
var _a;
|
|
365
|
-
const baseURL =
|
|
366
|
-
const getHeaders = () =>
|
|
366
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
367
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
367
368
|
{
|
|
368
|
-
Authorization: `Bearer ${
|
|
369
|
+
Authorization: `Bearer ${loadApiKey({
|
|
369
370
|
apiKey: options.apiKey,
|
|
370
371
|
environmentVariableName: "LUMA_API_KEY",
|
|
371
372
|
description: "Luma"
|
|
@@ -381,17 +382,17 @@ function createLuma(options = {}) {
|
|
|
381
382
|
fetch: options.fetch
|
|
382
383
|
});
|
|
383
384
|
const embeddingModel = (modelId) => {
|
|
384
|
-
throw new
|
|
385
|
+
throw new NoSuchModelError({
|
|
385
386
|
modelId,
|
|
386
387
|
modelType: "embeddingModel"
|
|
387
388
|
});
|
|
388
389
|
};
|
|
389
390
|
return {
|
|
390
|
-
specificationVersion: "
|
|
391
|
+
specificationVersion: "v4",
|
|
391
392
|
image: createImageModel,
|
|
392
393
|
imageModel: createImageModel,
|
|
393
394
|
languageModel: (modelId) => {
|
|
394
|
-
throw new
|
|
395
|
+
throw new NoSuchModelError({
|
|
395
396
|
modelId,
|
|
396
397
|
modelType: "languageModel"
|
|
397
398
|
});
|
|
@@ -401,10 +402,9 @@ function createLuma(options = {}) {
|
|
|
401
402
|
};
|
|
402
403
|
}
|
|
403
404
|
var luma = createLuma();
|
|
404
|
-
|
|
405
|
-
0 && (module.exports = {
|
|
405
|
+
export {
|
|
406
406
|
VERSION,
|
|
407
407
|
createLuma,
|
|
408
408
|
luma
|
|
409
|
-
}
|
|
409
|
+
};
|
|
410
410
|
//# sourceMappingURL=index.js.map
|