@ai-sdk/luma 3.0.0-beta.8 → 3.0.0-canary.32
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 +209 -0
- package/README.md +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +130 -119
- package/dist/index.js.map +1 -1
- package/package.json +11 -9
- package/src/index.ts +2 -2
- package/src/luma-image-model-options.ts +71 -0
- package/src/luma-image-model.ts +25 -68
- package/src/luma-provider.ts +7 -3
- 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,214 @@
|
|
|
1
1
|
# @ai-sdk/luma
|
|
2
2
|
|
|
3
|
+
## 3.0.0-canary.32
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0c4c275: trigger initial canary release
|
|
8
|
+
- Updated dependencies [0c4c275]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.0-canary.31
|
|
10
|
+
- @ai-sdk/provider@4.0.0-canary.15
|
|
11
|
+
|
|
12
|
+
## 3.0.0-beta.31
|
|
13
|
+
|
|
14
|
+
### Major Changes
|
|
15
|
+
|
|
16
|
+
- 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
|
|
17
|
+
|
|
18
|
+
For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [08d2129]
|
|
23
|
+
- @ai-sdk/provider-utils@5.0.0-beta.30
|
|
24
|
+
|
|
25
|
+
## 3.0.0-beta.30
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
30
|
+
- Updated dependencies [9bd6512]
|
|
31
|
+
- Updated dependencies [258c093]
|
|
32
|
+
- Updated dependencies [b6783da]
|
|
33
|
+
- @ai-sdk/provider-utils@5.0.0-beta.29
|
|
34
|
+
- @ai-sdk/provider@4.0.0-beta.14
|
|
35
|
+
|
|
36
|
+
## 3.0.0-beta.29
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
41
|
+
- Updated dependencies [9f0e36c]
|
|
42
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
43
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
44
|
+
|
|
45
|
+
## 3.0.0-beta.28
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- Updated dependencies [785fe16]
|
|
50
|
+
- Updated dependencies [67df0a0]
|
|
51
|
+
- Updated dependencies [befb78c]
|
|
52
|
+
- Updated dependencies [0458559]
|
|
53
|
+
- Updated dependencies [5852c0a]
|
|
54
|
+
- Updated dependencies [fc92055]
|
|
55
|
+
- @ai-sdk/provider-utils@5.0.0-beta.27
|
|
56
|
+
|
|
57
|
+
## 3.0.0-beta.27
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Updated dependencies [2e98477]
|
|
62
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
63
|
+
|
|
64
|
+
## 3.0.0-beta.26
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- Updated dependencies [eea8d98]
|
|
69
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
70
|
+
|
|
71
|
+
## 3.0.0-beta.25
|
|
72
|
+
|
|
73
|
+
### Patch Changes
|
|
74
|
+
|
|
75
|
+
- Updated dependencies [f807e45]
|
|
76
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
77
|
+
|
|
78
|
+
## 3.0.0-beta.24
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- Updated dependencies [350ea38]
|
|
83
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
84
|
+
|
|
85
|
+
## 3.0.0-beta.23
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- Updated dependencies [083947b]
|
|
90
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
91
|
+
|
|
92
|
+
## 3.0.0-beta.22
|
|
93
|
+
|
|
94
|
+
### Patch Changes
|
|
95
|
+
|
|
96
|
+
- Updated dependencies [add1126]
|
|
97
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
98
|
+
|
|
99
|
+
## 3.0.0-beta.21
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
104
|
+
|
|
105
|
+
**`@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.
|
|
106
|
+
|
|
107
|
+
**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.
|
|
108
|
+
|
|
109
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
110
|
+
|
|
111
|
+
- Updated dependencies [b3976a2]
|
|
112
|
+
- Updated dependencies [ff5eba1]
|
|
113
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
114
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
115
|
+
|
|
116
|
+
## 3.0.0-beta.20
|
|
117
|
+
|
|
118
|
+
### Major Changes
|
|
119
|
+
|
|
120
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- Updated dependencies [ef992f8]
|
|
125
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
126
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
127
|
+
|
|
128
|
+
## 3.0.0-beta.19
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
133
|
+
- Updated dependencies [90e2d8a]
|
|
134
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
135
|
+
|
|
136
|
+
## 3.0.0-beta.18
|
|
137
|
+
|
|
138
|
+
### Patch Changes
|
|
139
|
+
|
|
140
|
+
- Updated dependencies [3ae1786]
|
|
141
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
142
|
+
|
|
143
|
+
## 3.0.0-beta.17
|
|
144
|
+
|
|
145
|
+
### Patch Changes
|
|
146
|
+
|
|
147
|
+
- Updated dependencies [176466a]
|
|
148
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
149
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
150
|
+
|
|
151
|
+
## 3.0.0-beta.16
|
|
152
|
+
|
|
153
|
+
### Patch Changes
|
|
154
|
+
|
|
155
|
+
- Updated dependencies [e311194]
|
|
156
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
157
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
158
|
+
|
|
159
|
+
## 3.0.0-beta.15
|
|
160
|
+
|
|
161
|
+
### Patch Changes
|
|
162
|
+
|
|
163
|
+
- Updated dependencies [34bd95d]
|
|
164
|
+
- Updated dependencies [008271d]
|
|
165
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
166
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
167
|
+
|
|
168
|
+
## 3.0.0-beta.14
|
|
169
|
+
|
|
170
|
+
### Patch Changes
|
|
171
|
+
|
|
172
|
+
- Updated dependencies [b0c2869]
|
|
173
|
+
- Updated dependencies [7e26e81]
|
|
174
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
175
|
+
|
|
176
|
+
## 3.0.0-beta.13
|
|
177
|
+
|
|
178
|
+
### Patch Changes
|
|
179
|
+
|
|
180
|
+
- Updated dependencies [46d1149]
|
|
181
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
182
|
+
|
|
183
|
+
## 3.0.0-beta.12
|
|
184
|
+
|
|
185
|
+
### Patch Changes
|
|
186
|
+
|
|
187
|
+
- Updated dependencies [6fd51c0]
|
|
188
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
189
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
190
|
+
|
|
191
|
+
## 3.0.0-beta.11
|
|
192
|
+
|
|
193
|
+
### Patch Changes
|
|
194
|
+
|
|
195
|
+
- Updated dependencies [c29a26f]
|
|
196
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
197
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
198
|
+
|
|
199
|
+
## 3.0.0-beta.10
|
|
200
|
+
|
|
201
|
+
### Patch Changes
|
|
202
|
+
|
|
203
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
204
|
+
|
|
205
|
+
## 3.0.0-beta.9
|
|
206
|
+
|
|
207
|
+
### Patch Changes
|
|
208
|
+
|
|
209
|
+
- Updated dependencies [2e17091]
|
|
210
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
211
|
+
|
|
3
212
|
## 3.0.0-beta.8
|
|
4
213
|
|
|
5
214
|
### Patch Changes
|
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
package/dist/index.js
CHANGED
|
@@ -1,42 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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);
|
|
1
|
+
// src/luma-provider.ts
|
|
2
|
+
import {
|
|
3
|
+
NoSuchModelError
|
|
4
|
+
} from "@ai-sdk/provider";
|
|
5
|
+
import {
|
|
6
|
+
loadApiKey,
|
|
7
|
+
withoutTrailingSlash,
|
|
8
|
+
withUserAgentSuffix
|
|
9
|
+
} from "@ai-sdk/provider-utils";
|
|
19
10
|
|
|
20
|
-
// src/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
// src/luma-image-model.ts
|
|
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 as lazySchema2,
|
|
25
|
+
parseProviderOptions,
|
|
26
|
+
zodSchema as zodSchema2,
|
|
27
|
+
serializeModelOptions,
|
|
28
|
+
WORKFLOW_SERIALIZE,
|
|
29
|
+
WORKFLOW_DESERIALIZE
|
|
30
|
+
} from "@ai-sdk/provider-utils";
|
|
28
31
|
|
|
29
|
-
// src/luma-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
// src/luma-image-model-options.ts
|
|
33
|
+
import {
|
|
34
|
+
lazySchema,
|
|
35
|
+
zodSchema
|
|
36
|
+
} from "@ai-sdk/provider-utils";
|
|
37
|
+
import { z } from "zod/v4";
|
|
38
|
+
var lumaImageModelOptionsSchema = lazySchema(
|
|
39
|
+
() => zodSchema(
|
|
40
|
+
z.object({
|
|
41
|
+
/**
|
|
42
|
+
* The type of image reference to use when providing input images.
|
|
43
|
+
* - `image`: Guide generation using reference images (up to 4). Default.
|
|
44
|
+
* - `style`: Apply a specific style from reference image(s).
|
|
45
|
+
* - `character`: Create consistent characters from reference images (up to 4).
|
|
46
|
+
* - `modify_image`: Transform a single input image with prompt guidance.
|
|
47
|
+
*/
|
|
48
|
+
referenceType: z.enum(["image", "style", "character", "modify_image"]).nullish(),
|
|
49
|
+
/**
|
|
50
|
+
* Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
|
|
51
|
+
* Allows setting individual weights for each reference image.
|
|
52
|
+
*/
|
|
53
|
+
images: z.array(
|
|
54
|
+
z.object({
|
|
55
|
+
/**
|
|
56
|
+
* The weight of this image's influence on the generation.
|
|
57
|
+
* - For `image`: Higher weight = closer to reference (default: 0.85)
|
|
58
|
+
* - For `style`: Higher weight = stronger style influence (default: 0.8)
|
|
59
|
+
* - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
|
|
60
|
+
*/
|
|
61
|
+
weight: z.number().min(0).max(1).nullish(),
|
|
62
|
+
/**
|
|
63
|
+
* The identity name for character references.
|
|
64
|
+
* Used with `character` to specify which identity group the image belongs to.
|
|
65
|
+
* Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating
|
|
66
|
+
* images with multiple consistent characters.
|
|
67
|
+
* Default: 'identity0'
|
|
68
|
+
*/
|
|
69
|
+
id: z.string().nullish()
|
|
70
|
+
})
|
|
71
|
+
).nullish(),
|
|
72
|
+
/**
|
|
73
|
+
* Override the polling interval in milliseconds (default 500).
|
|
74
|
+
*/
|
|
75
|
+
pollIntervalMillis: z.number().nullish(),
|
|
76
|
+
/**
|
|
77
|
+
* Override the maximum number of polling attempts (default 120).
|
|
78
|
+
*/
|
|
79
|
+
maxPollAttempts: z.number().nullish()
|
|
80
|
+
}).passthrough()
|
|
81
|
+
)
|
|
82
|
+
);
|
|
32
83
|
|
|
33
84
|
// src/luma-image-model.ts
|
|
34
|
-
|
|
35
|
-
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
36
|
-
var import_v4 = require("zod/v4");
|
|
85
|
+
import { z as z2 } from "zod/v4";
|
|
37
86
|
var DEFAULT_POLL_INTERVAL_MILLIS = 500;
|
|
38
87
|
var DEFAULT_MAX_POLL_ATTEMPTS = 6e4 / DEFAULT_POLL_INTERVAL_MILLIS;
|
|
39
|
-
var LumaImageModel = class {
|
|
88
|
+
var LumaImageModel = class _LumaImageModel {
|
|
40
89
|
constructor(modelId, config) {
|
|
41
90
|
this.modelId = modelId;
|
|
42
91
|
this.config = config;
|
|
@@ -48,9 +97,17 @@ var LumaImageModel = class {
|
|
|
48
97
|
get provider() {
|
|
49
98
|
return this.config.provider;
|
|
50
99
|
}
|
|
100
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
101
|
+
return serializeModelOptions({
|
|
102
|
+
modelId: model.modelId,
|
|
103
|
+
config: model.config
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
107
|
+
return new _LumaImageModel(options.modelId, options.config);
|
|
108
|
+
}
|
|
51
109
|
async doGenerate({
|
|
52
110
|
prompt,
|
|
53
|
-
n,
|
|
54
111
|
size,
|
|
55
112
|
aspectRatio,
|
|
56
113
|
seed,
|
|
@@ -60,7 +117,7 @@ var LumaImageModel = class {
|
|
|
60
117
|
files,
|
|
61
118
|
mask
|
|
62
119
|
}) {
|
|
63
|
-
var _a, _b, _c;
|
|
120
|
+
var _a, _b, _c, _d, _e;
|
|
64
121
|
const warnings = [];
|
|
65
122
|
if (seed != null) {
|
|
66
123
|
warnings.push({
|
|
@@ -76,7 +133,7 @@ var LumaImageModel = class {
|
|
|
76
133
|
details: "This model does not support the `size` option. Use `aspectRatio` instead."
|
|
77
134
|
});
|
|
78
135
|
}
|
|
79
|
-
const lumaOptions = await
|
|
136
|
+
const lumaOptions = await parseProviderOptions({
|
|
80
137
|
provider: "luma",
|
|
81
138
|
providerOptions,
|
|
82
139
|
schema: lumaImageModelOptionsSchema
|
|
@@ -95,8 +152,8 @@ var LumaImageModel = class {
|
|
|
95
152
|
imageConfigs != null ? imageConfigs : []
|
|
96
153
|
);
|
|
97
154
|
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
|
|
155
|
+
const fullHeaders = combineHeaders((_e = (_d = this.config).headers) == null ? void 0 : _e.call(_d), headers);
|
|
156
|
+
const { value: generationResponse, responseHeaders } = await postJsonToApi({
|
|
100
157
|
url: this.getLumaGenerationsUrl(),
|
|
101
158
|
headers: fullHeaders,
|
|
102
159
|
body: {
|
|
@@ -109,7 +166,7 @@ var LumaImageModel = class {
|
|
|
109
166
|
abortSignal,
|
|
110
167
|
fetch: this.config.fetch,
|
|
111
168
|
failedResponseHandler: this.createLumaErrorHandler(),
|
|
112
|
-
successfulResponseHandler:
|
|
169
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
113
170
|
lumaGenerationResponseSchema
|
|
114
171
|
)
|
|
115
172
|
});
|
|
@@ -139,39 +196,39 @@ var LumaImageModel = class {
|
|
|
139
196
|
const maxPollAttempts = (_a = pollSettings == null ? void 0 : pollSettings.maxPollAttempts) != null ? _a : this.maxPollAttempts;
|
|
140
197
|
const pollIntervalMillis = (_b = pollSettings == null ? void 0 : pollSettings.pollIntervalMillis) != null ? _b : this.pollIntervalMillis;
|
|
141
198
|
for (let i = 0; i < maxPollAttempts; i++) {
|
|
142
|
-
const { value: statusResponse } = await
|
|
199
|
+
const { value: statusResponse } = await getFromApi({
|
|
143
200
|
url,
|
|
144
201
|
headers,
|
|
145
202
|
abortSignal,
|
|
146
203
|
fetch: this.config.fetch,
|
|
147
204
|
failedResponseHandler: this.createLumaErrorHandler(),
|
|
148
|
-
successfulResponseHandler:
|
|
205
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
149
206
|
lumaGenerationResponseSchema
|
|
150
207
|
)
|
|
151
208
|
});
|
|
152
209
|
switch (statusResponse.state) {
|
|
153
210
|
case "completed":
|
|
154
211
|
if (!((_c = statusResponse.assets) == null ? void 0 : _c.image)) {
|
|
155
|
-
throw new
|
|
212
|
+
throw new InvalidResponseDataError({
|
|
156
213
|
data: statusResponse,
|
|
157
214
|
message: `Image generation completed but no image was found.`
|
|
158
215
|
});
|
|
159
216
|
}
|
|
160
217
|
return statusResponse.assets.image;
|
|
161
218
|
case "failed":
|
|
162
|
-
throw new
|
|
219
|
+
throw new InvalidResponseDataError({
|
|
163
220
|
data: statusResponse,
|
|
164
221
|
message: `Image generation failed.`
|
|
165
222
|
});
|
|
166
223
|
}
|
|
167
|
-
await
|
|
224
|
+
await delay(pollIntervalMillis);
|
|
168
225
|
}
|
|
169
226
|
throw new Error(
|
|
170
227
|
`Image generation timed out after ${this.maxPollAttempts} attempts.`
|
|
171
228
|
);
|
|
172
229
|
}
|
|
173
230
|
createLumaErrorHandler() {
|
|
174
|
-
return
|
|
231
|
+
return createJsonErrorResponseHandler({
|
|
175
232
|
errorSchema: lumaErrorSchema,
|
|
176
233
|
errorToMessage: (error) => {
|
|
177
234
|
var _a;
|
|
@@ -271,101 +328,56 @@ var LumaImageModel = class {
|
|
|
271
328
|
return `${this.config.baseURL}/dream-machine/v1/generations/${generationId != null ? generationId : "image"}`;
|
|
272
329
|
}
|
|
273
330
|
async downloadImage(url, abortSignal) {
|
|
274
|
-
const { value: response } = await
|
|
331
|
+
const { value: response } = await getFromApi({
|
|
275
332
|
url,
|
|
276
333
|
// No specific headers should be needed for this request as it's a
|
|
277
334
|
// generated image provided by Luma.
|
|
278
335
|
abortSignal,
|
|
279
|
-
failedResponseHandler:
|
|
280
|
-
successfulResponseHandler:
|
|
336
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
337
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
281
338
|
fetch: this.config.fetch
|
|
282
339
|
});
|
|
283
340
|
return response;
|
|
284
341
|
}
|
|
285
342
|
};
|
|
286
|
-
var lumaGenerationResponseSchema = (
|
|
287
|
-
() => (
|
|
288
|
-
|
|
289
|
-
id:
|
|
290
|
-
state:
|
|
291
|
-
failure_reason:
|
|
292
|
-
assets:
|
|
293
|
-
image:
|
|
343
|
+
var lumaGenerationResponseSchema = lazySchema2(
|
|
344
|
+
() => zodSchema2(
|
|
345
|
+
z2.object({
|
|
346
|
+
id: z2.string(),
|
|
347
|
+
state: z2.enum(["queued", "dreaming", "completed", "failed"]),
|
|
348
|
+
failure_reason: z2.string().nullish(),
|
|
349
|
+
assets: z2.object({
|
|
350
|
+
image: z2.string()
|
|
294
351
|
// URL of the generated image
|
|
295
352
|
}).nullish()
|
|
296
353
|
})
|
|
297
354
|
)
|
|
298
355
|
);
|
|
299
|
-
var lumaErrorSchema =
|
|
300
|
-
detail:
|
|
301
|
-
|
|
302
|
-
type:
|
|
303
|
-
loc:
|
|
304
|
-
msg:
|
|
305
|
-
input:
|
|
306
|
-
ctx:
|
|
307
|
-
expected:
|
|
356
|
+
var lumaErrorSchema = z2.object({
|
|
357
|
+
detail: z2.array(
|
|
358
|
+
z2.object({
|
|
359
|
+
type: z2.string(),
|
|
360
|
+
loc: z2.array(z2.string()),
|
|
361
|
+
msg: z2.string(),
|
|
362
|
+
input: z2.string(),
|
|
363
|
+
ctx: z2.object({
|
|
364
|
+
expected: z2.string()
|
|
308
365
|
}).nullish()
|
|
309
366
|
})
|
|
310
367
|
)
|
|
311
368
|
});
|
|
312
|
-
var lumaImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
313
|
-
() => (0, import_provider_utils.zodSchema)(
|
|
314
|
-
import_v4.z.object({
|
|
315
|
-
/**
|
|
316
|
-
* The type of image reference to use when providing input images.
|
|
317
|
-
* - `image`: Guide generation using reference images (up to 4). Default.
|
|
318
|
-
* - `style`: Apply a specific style from reference image(s).
|
|
319
|
-
* - `character`: Create consistent characters from reference images (up to 4).
|
|
320
|
-
* - `modify_image`: Transform a single input image with prompt guidance.
|
|
321
|
-
*/
|
|
322
|
-
referenceType: import_v4.z.enum(["image", "style", "character", "modify_image"]).nullish(),
|
|
323
|
-
/**
|
|
324
|
-
* Per-image configuration array. Each entry corresponds to an image in `prompt.images`.
|
|
325
|
-
* Allows setting individual weights for each reference image.
|
|
326
|
-
*/
|
|
327
|
-
images: import_v4.z.array(
|
|
328
|
-
import_v4.z.object({
|
|
329
|
-
/**
|
|
330
|
-
* The weight of this image's influence on the generation.
|
|
331
|
-
* - For `image`: Higher weight = closer to reference (default: 0.85)
|
|
332
|
-
* - For `style`: Higher weight = stronger style influence (default: 0.8)
|
|
333
|
-
* - For `modify_image`: Higher weight = closer to input, lower = more creative (default: 1.0)
|
|
334
|
-
*/
|
|
335
|
-
weight: import_v4.z.number().min(0).max(1).nullish(),
|
|
336
|
-
/**
|
|
337
|
-
* The identity name for character references.
|
|
338
|
-
* Used with `character` to specify which identity group the image belongs to.
|
|
339
|
-
* Luma supports multiple identities (e.g., 'identity0', 'identity1') for generating
|
|
340
|
-
* images with multiple consistent characters.
|
|
341
|
-
* Default: 'identity0'
|
|
342
|
-
*/
|
|
343
|
-
id: import_v4.z.string().nullish()
|
|
344
|
-
})
|
|
345
|
-
).nullish(),
|
|
346
|
-
/**
|
|
347
|
-
* Override the polling interval in milliseconds (default 500).
|
|
348
|
-
*/
|
|
349
|
-
pollIntervalMillis: import_v4.z.number().nullish(),
|
|
350
|
-
/**
|
|
351
|
-
* Override the maximum number of polling attempts (default 120).
|
|
352
|
-
*/
|
|
353
|
-
maxPollAttempts: import_v4.z.number().nullish()
|
|
354
|
-
}).passthrough()
|
|
355
|
-
)
|
|
356
|
-
);
|
|
357
369
|
|
|
358
370
|
// src/version.ts
|
|
359
|
-
var VERSION = true ? "3.0.0-
|
|
371
|
+
var VERSION = true ? "3.0.0-canary.32" : "0.0.0-test";
|
|
360
372
|
|
|
361
373
|
// src/luma-provider.ts
|
|
362
374
|
var defaultBaseURL = "https://api.lumalabs.ai";
|
|
363
375
|
function createLuma(options = {}) {
|
|
364
376
|
var _a;
|
|
365
|
-
const baseURL =
|
|
366
|
-
const getHeaders = () =>
|
|
377
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
378
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
367
379
|
{
|
|
368
|
-
Authorization: `Bearer ${
|
|
380
|
+
Authorization: `Bearer ${loadApiKey({
|
|
369
381
|
apiKey: options.apiKey,
|
|
370
382
|
environmentVariableName: "LUMA_API_KEY",
|
|
371
383
|
description: "Luma"
|
|
@@ -381,7 +393,7 @@ function createLuma(options = {}) {
|
|
|
381
393
|
fetch: options.fetch
|
|
382
394
|
});
|
|
383
395
|
const embeddingModel = (modelId) => {
|
|
384
|
-
throw new
|
|
396
|
+
throw new NoSuchModelError({
|
|
385
397
|
modelId,
|
|
386
398
|
modelType: "embeddingModel"
|
|
387
399
|
});
|
|
@@ -391,7 +403,7 @@ function createLuma(options = {}) {
|
|
|
391
403
|
image: createImageModel,
|
|
392
404
|
imageModel: createImageModel,
|
|
393
405
|
languageModel: (modelId) => {
|
|
394
|
-
throw new
|
|
406
|
+
throw new NoSuchModelError({
|
|
395
407
|
modelId,
|
|
396
408
|
modelType: "languageModel"
|
|
397
409
|
});
|
|
@@ -401,10 +413,9 @@ function createLuma(options = {}) {
|
|
|
401
413
|
};
|
|
402
414
|
}
|
|
403
415
|
var luma = createLuma();
|
|
404
|
-
|
|
405
|
-
0 && (module.exports = {
|
|
416
|
+
export {
|
|
406
417
|
VERSION,
|
|
407
418
|
createLuma,
|
|
408
419
|
luma
|
|
409
|
-
}
|
|
420
|
+
};
|
|
410
421
|
//# sourceMappingURL=index.js.map
|