@ai-sdk/black-forest-labs 2.0.0-beta.3 → 2.0.0-beta.31
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 +242 -4
- package/README.md +2 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +128 -119
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/black-forest-labs-image-model-options.ts +51 -0
- package/src/black-forest-labs-image-model.ts +32 -59
- package/src/black-forest-labs-provider.ts +11 -7
- package/src/index.ts +1 -1
- package/dist/index.d.mts +0 -82
- package/dist/index.mjs +0 -436
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,243 @@
|
|
|
1
1
|
# @ai-sdk/black-forest-labs
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.31
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 04e9009: chore: make provider implementations code patterns more consistent, including renaming certain exported symbols
|
|
8
|
+
|
|
9
|
+
For all externally exported symbols that were renamed, the old names continue to work via deprecated aliases.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [08d2129]
|
|
14
|
+
- @ai-sdk/provider-utils@5.0.0-beta.30
|
|
15
|
+
|
|
16
|
+
## 2.0.0-beta.30
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
21
|
+
- Updated dependencies [9bd6512]
|
|
22
|
+
- Updated dependencies [258c093]
|
|
23
|
+
- Updated dependencies [b6783da]
|
|
24
|
+
- @ai-sdk/provider-utils@5.0.0-beta.29
|
|
25
|
+
- @ai-sdk/provider@4.0.0-beta.14
|
|
26
|
+
|
|
27
|
+
## 2.0.0-beta.29
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
32
|
+
- Updated dependencies [9f0e36c]
|
|
33
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
34
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
35
|
+
|
|
36
|
+
## 2.0.0-beta.28
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [785fe16]
|
|
41
|
+
- Updated dependencies [67df0a0]
|
|
42
|
+
- Updated dependencies [befb78c]
|
|
43
|
+
- Updated dependencies [0458559]
|
|
44
|
+
- Updated dependencies [5852c0a]
|
|
45
|
+
- Updated dependencies [fc92055]
|
|
46
|
+
- @ai-sdk/provider-utils@5.0.0-beta.27
|
|
47
|
+
|
|
48
|
+
## 2.0.0-beta.27
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [2e98477]
|
|
53
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
54
|
+
|
|
55
|
+
## 2.0.0-beta.26
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [eea8d98]
|
|
60
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
61
|
+
|
|
62
|
+
## 2.0.0-beta.25
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- Updated dependencies [f807e45]
|
|
67
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
68
|
+
|
|
69
|
+
## 2.0.0-beta.24
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies [350ea38]
|
|
74
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
75
|
+
|
|
76
|
+
## 2.0.0-beta.23
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- Updated dependencies [083947b]
|
|
81
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
82
|
+
|
|
83
|
+
## 2.0.0-beta.22
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- Updated dependencies [add1126]
|
|
88
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
89
|
+
|
|
90
|
+
## 2.0.0-beta.21
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
95
|
+
|
|
96
|
+
**`@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.
|
|
97
|
+
|
|
98
|
+
**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.
|
|
99
|
+
|
|
100
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
101
|
+
|
|
102
|
+
- Updated dependencies [b3976a2]
|
|
103
|
+
- Updated dependencies [ff5eba1]
|
|
104
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
105
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
106
|
+
|
|
107
|
+
## 2.0.0-beta.20
|
|
108
|
+
|
|
109
|
+
### Major Changes
|
|
110
|
+
|
|
111
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- Updated dependencies [ef992f8]
|
|
116
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
117
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
118
|
+
|
|
119
|
+
## 2.0.0-beta.19
|
|
120
|
+
|
|
121
|
+
### Patch Changes
|
|
122
|
+
|
|
123
|
+
- Updated dependencies [90e2d8a]
|
|
124
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
125
|
+
|
|
126
|
+
## 2.0.0-beta.18
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Updated dependencies [3ae1786]
|
|
131
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
132
|
+
|
|
133
|
+
## 2.0.0-beta.17
|
|
134
|
+
|
|
135
|
+
### Patch Changes
|
|
136
|
+
|
|
137
|
+
- Updated dependencies [176466a]
|
|
138
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
139
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
140
|
+
|
|
141
|
+
## 2.0.0-beta.16
|
|
142
|
+
|
|
143
|
+
### Patch Changes
|
|
144
|
+
|
|
145
|
+
- Updated dependencies [e311194]
|
|
146
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
147
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
148
|
+
|
|
149
|
+
## 2.0.0-beta.15
|
|
150
|
+
|
|
151
|
+
### Patch Changes
|
|
152
|
+
|
|
153
|
+
- Updated dependencies [34bd95d]
|
|
154
|
+
- Updated dependencies [008271d]
|
|
155
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
156
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
157
|
+
|
|
158
|
+
## 2.0.0-beta.14
|
|
159
|
+
|
|
160
|
+
### Patch Changes
|
|
161
|
+
|
|
162
|
+
- Updated dependencies [b0c2869]
|
|
163
|
+
- Updated dependencies [7e26e81]
|
|
164
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
165
|
+
|
|
166
|
+
## 2.0.0-beta.13
|
|
167
|
+
|
|
168
|
+
### Patch Changes
|
|
169
|
+
|
|
170
|
+
- Updated dependencies [46d1149]
|
|
171
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
172
|
+
|
|
173
|
+
## 2.0.0-beta.12
|
|
174
|
+
|
|
175
|
+
### Patch Changes
|
|
176
|
+
|
|
177
|
+
- Updated dependencies [6fd51c0]
|
|
178
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
179
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
180
|
+
|
|
181
|
+
## 2.0.0-beta.11
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- Updated dependencies [c29a26f]
|
|
186
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
187
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
188
|
+
|
|
189
|
+
## 2.0.0-beta.10
|
|
190
|
+
|
|
191
|
+
### Patch Changes
|
|
192
|
+
|
|
193
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
194
|
+
|
|
195
|
+
## 2.0.0-beta.9
|
|
196
|
+
|
|
197
|
+
### Patch Changes
|
|
198
|
+
|
|
199
|
+
- Updated dependencies [2e17091]
|
|
200
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
201
|
+
|
|
202
|
+
## 2.0.0-beta.8
|
|
203
|
+
|
|
204
|
+
### Patch Changes
|
|
205
|
+
|
|
206
|
+
- Updated dependencies [986c6fd]
|
|
207
|
+
- Updated dependencies [493295c]
|
|
208
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
209
|
+
|
|
210
|
+
## 2.0.0-beta.7
|
|
211
|
+
|
|
212
|
+
### Patch Changes
|
|
213
|
+
|
|
214
|
+
- Updated dependencies [1f509d4]
|
|
215
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
216
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
217
|
+
|
|
218
|
+
## 2.0.0-beta.6
|
|
219
|
+
|
|
220
|
+
### Patch Changes
|
|
221
|
+
|
|
222
|
+
- Updated dependencies [3887c70]
|
|
223
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
224
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
225
|
+
|
|
226
|
+
## 2.0.0-beta.5
|
|
227
|
+
|
|
228
|
+
### Patch Changes
|
|
229
|
+
|
|
230
|
+
- Updated dependencies [776b617]
|
|
231
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
232
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
233
|
+
|
|
234
|
+
## 2.0.0-beta.4
|
|
235
|
+
|
|
236
|
+
### Patch Changes
|
|
237
|
+
|
|
238
|
+
- Updated dependencies [61753c3]
|
|
239
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
240
|
+
|
|
3
241
|
## 2.0.0-beta.3
|
|
4
242
|
|
|
5
243
|
### Patch Changes
|
|
@@ -222,13 +460,13 @@
|
|
|
222
460
|
Before
|
|
223
461
|
|
|
224
462
|
```ts
|
|
225
|
-
model.textEmbeddingModel(
|
|
463
|
+
model.textEmbeddingModel("my-model-id");
|
|
226
464
|
```
|
|
227
465
|
|
|
228
466
|
After
|
|
229
467
|
|
|
230
468
|
```ts
|
|
231
|
-
model.embeddingModel(
|
|
469
|
+
model.embeddingModel("my-model-id");
|
|
232
470
|
```
|
|
233
471
|
|
|
234
472
|
- cd3b71c: feat (provider/black-forest-labs): include cost and megapixels in metadata
|
|
@@ -427,13 +665,13 @@
|
|
|
427
665
|
Before
|
|
428
666
|
|
|
429
667
|
```ts
|
|
430
|
-
model.textEmbeddingModel(
|
|
668
|
+
model.textEmbeddingModel("my-model-id");
|
|
431
669
|
```
|
|
432
670
|
|
|
433
671
|
After
|
|
434
672
|
|
|
435
673
|
```ts
|
|
436
|
-
model.embeddingModel(
|
|
674
|
+
model.embeddingModel("my-model-id");
|
|
437
675
|
```
|
|
438
676
|
|
|
439
677
|
- Updated dependencies [8d9e8ad]
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The **[Black Forest Labs provider](https://ai-sdk.dev/providers/ai-sdk-providers/black-forest-labs)** for the [AI SDK](https://ai-sdk.dev/docs) adds image model support for the [Black Forest Labs API](https://docs.bfl.ai/).
|
|
4
4
|
|
|
5
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access Black Forest Labs (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).
|
|
6
|
+
|
|
5
7
|
## Setup
|
|
6
8
|
|
|
7
9
|
The Black Forest Labs provider is available in the `@ai-sdk/black-forest-labs` 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
|
|
|
@@ -32,15 +32,15 @@ interface BlackForestLabsProviderSettings {
|
|
|
32
32
|
*/
|
|
33
33
|
pollTimeoutMillis?: number;
|
|
34
34
|
}
|
|
35
|
-
interface BlackForestLabsProvider extends
|
|
35
|
+
interface BlackForestLabsProvider extends ProviderV4 {
|
|
36
36
|
/**
|
|
37
37
|
* Creates a model for image generation.
|
|
38
38
|
*/
|
|
39
|
-
image(modelId: BlackForestLabsImageModelId):
|
|
39
|
+
image(modelId: BlackForestLabsImageModelId): ImageModelV4;
|
|
40
40
|
/**
|
|
41
41
|
* Creates a model for image generation.
|
|
42
42
|
*/
|
|
43
|
-
imageModel(modelId: BlackForestLabsImageModelId):
|
|
43
|
+
imageModel(modelId: BlackForestLabsImageModelId): ImageModelV4;
|
|
44
44
|
/**
|
|
45
45
|
* @deprecated Use `embeddingModel` instead.
|
|
46
46
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1,50 +1,100 @@
|
|
|
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/black-forest-labs-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/black-forest-labs-image-model.ts
|
|
12
|
+
import {
|
|
13
|
+
combineHeaders,
|
|
14
|
+
createBinaryResponseHandler,
|
|
15
|
+
createJsonErrorResponseHandler,
|
|
16
|
+
createJsonResponseHandler,
|
|
17
|
+
createStatusCodeErrorResponseHandler,
|
|
18
|
+
delay,
|
|
19
|
+
getFromApi,
|
|
20
|
+
parseProviderOptions,
|
|
21
|
+
postJsonToApi,
|
|
22
|
+
resolve,
|
|
23
|
+
serializeModelOptions,
|
|
24
|
+
WORKFLOW_SERIALIZE,
|
|
25
|
+
WORKFLOW_DESERIALIZE
|
|
26
|
+
} from "@ai-sdk/provider-utils";
|
|
27
|
+
import { z as z2 } from "zod/v4";
|
|
28
28
|
|
|
29
|
-
// src/black-forest-labs-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// src/black-forest-labs-image-model-options.ts
|
|
30
|
+
import {
|
|
31
|
+
lazySchema,
|
|
32
|
+
zodSchema
|
|
33
|
+
} from "@ai-sdk/provider-utils";
|
|
34
|
+
import { z } from "zod/v4";
|
|
35
|
+
var blackForestLabsImageModelOptionsSchema = lazySchema(
|
|
36
|
+
() => zodSchema(
|
|
37
|
+
z.object({
|
|
38
|
+
imagePrompt: z.string().optional(),
|
|
39
|
+
imagePromptStrength: z.number().min(0).max(1).optional(),
|
|
40
|
+
/** @deprecated use prompt.images instead */
|
|
41
|
+
inputImage: z.string().optional(),
|
|
42
|
+
/** @deprecated use prompt.images instead */
|
|
43
|
+
inputImage2: z.string().optional(),
|
|
44
|
+
/** @deprecated use prompt.images instead */
|
|
45
|
+
inputImage3: z.string().optional(),
|
|
46
|
+
/** @deprecated use prompt.images instead */
|
|
47
|
+
inputImage4: z.string().optional(),
|
|
48
|
+
/** @deprecated use prompt.images instead */
|
|
49
|
+
inputImage5: z.string().optional(),
|
|
50
|
+
/** @deprecated use prompt.images instead */
|
|
51
|
+
inputImage6: z.string().optional(),
|
|
52
|
+
/** @deprecated use prompt.images instead */
|
|
53
|
+
inputImage7: z.string().optional(),
|
|
54
|
+
/** @deprecated use prompt.images instead */
|
|
55
|
+
inputImage8: z.string().optional(),
|
|
56
|
+
/** @deprecated use prompt.images instead */
|
|
57
|
+
inputImage9: z.string().optional(),
|
|
58
|
+
/** @deprecated use prompt.images instead */
|
|
59
|
+
inputImage10: z.string().optional(),
|
|
60
|
+
steps: z.number().int().positive().optional(),
|
|
61
|
+
guidance: z.number().min(0).optional(),
|
|
62
|
+
width: z.number().int().min(256).max(1920).optional(),
|
|
63
|
+
height: z.number().int().min(256).max(1920).optional(),
|
|
64
|
+
outputFormat: z.enum(["jpeg", "png"]).optional(),
|
|
65
|
+
promptUpsampling: z.boolean().optional(),
|
|
66
|
+
raw: z.boolean().optional(),
|
|
67
|
+
safetyTolerance: z.number().int().min(0).max(6).optional(),
|
|
68
|
+
webhookSecret: z.string().optional(),
|
|
69
|
+
webhookUrl: z.url().optional(),
|
|
70
|
+
pollIntervalMillis: z.number().int().positive().optional(),
|
|
71
|
+
pollTimeoutMillis: z.number().int().positive().optional()
|
|
72
|
+
})
|
|
73
|
+
)
|
|
74
|
+
);
|
|
32
75
|
|
|
33
76
|
// src/black-forest-labs-image-model.ts
|
|
34
|
-
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
35
|
-
var import_v4 = require("zod/v4");
|
|
36
77
|
var DEFAULT_POLL_INTERVAL_MILLIS = 500;
|
|
37
78
|
var DEFAULT_POLL_TIMEOUT_MILLIS = 6e4;
|
|
38
|
-
var BlackForestLabsImageModel = class {
|
|
79
|
+
var BlackForestLabsImageModel = class _BlackForestLabsImageModel {
|
|
39
80
|
constructor(modelId, config) {
|
|
40
81
|
this.modelId = modelId;
|
|
41
82
|
this.config = config;
|
|
42
|
-
this.specificationVersion = "
|
|
83
|
+
this.specificationVersion = "v4";
|
|
43
84
|
this.maxImagesPerCall = 1;
|
|
44
85
|
}
|
|
45
86
|
get provider() {
|
|
46
87
|
return this.config.provider;
|
|
47
88
|
}
|
|
89
|
+
static [WORKFLOW_SERIALIZE](model) {
|
|
90
|
+
return serializeModelOptions({
|
|
91
|
+
modelId: model.modelId,
|
|
92
|
+
config: model.config
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
static [WORKFLOW_DESERIALIZE](options) {
|
|
96
|
+
return new _BlackForestLabsImageModel(options.modelId, options.config);
|
|
97
|
+
}
|
|
48
98
|
async getArgs({
|
|
49
99
|
prompt,
|
|
50
100
|
files,
|
|
@@ -70,7 +120,7 @@ var BlackForestLabsImageModel = class {
|
|
|
70
120
|
details: "Black Forest Labs ignores size when aspectRatio is provided. Use the width and height provider options to specify dimensions for models that support them"
|
|
71
121
|
});
|
|
72
122
|
}
|
|
73
|
-
const bflOptions = await
|
|
123
|
+
const bflOptions = await parseProviderOptions({
|
|
74
124
|
provider: "blackForestLabs",
|
|
75
125
|
providerOptions,
|
|
76
126
|
schema: blackForestLabsImageModelOptionsSchema
|
|
@@ -149,22 +199,22 @@ var BlackForestLabsImageModel = class {
|
|
|
149
199
|
headers,
|
|
150
200
|
abortSignal
|
|
151
201
|
});
|
|
152
|
-
const bflOptions = await
|
|
202
|
+
const bflOptions = await parseProviderOptions({
|
|
153
203
|
provider: "blackForestLabs",
|
|
154
204
|
providerOptions,
|
|
155
205
|
schema: blackForestLabsImageModelOptionsSchema
|
|
156
206
|
});
|
|
157
207
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
158
|
-
const combinedHeaders =
|
|
159
|
-
await
|
|
208
|
+
const combinedHeaders = combineHeaders(
|
|
209
|
+
await resolve(this.config.headers),
|
|
160
210
|
headers
|
|
161
211
|
);
|
|
162
|
-
const submit = await
|
|
212
|
+
const submit = await postJsonToApi({
|
|
163
213
|
url: `${this.config.baseURL}/${this.modelId}`,
|
|
164
214
|
headers: combinedHeaders,
|
|
165
215
|
body,
|
|
166
216
|
failedResponseHandler: bflFailedResponseHandler,
|
|
167
|
-
successfulResponseHandler:
|
|
217
|
+
successfulResponseHandler: createJsonResponseHandler(bflSubmitSchema),
|
|
168
218
|
abortSignal,
|
|
169
219
|
fetch: this.config.fetch
|
|
170
220
|
});
|
|
@@ -186,12 +236,12 @@ var BlackForestLabsImageModel = class {
|
|
|
186
236
|
pollTimeoutMillis: bflOptions == null ? void 0 : bflOptions.pollTimeoutMillis
|
|
187
237
|
}
|
|
188
238
|
});
|
|
189
|
-
const { value: imageBytes, responseHeaders } = await
|
|
239
|
+
const { value: imageBytes, responseHeaders } = await getFromApi({
|
|
190
240
|
url: imageUrl,
|
|
191
241
|
headers: combinedHeaders,
|
|
192
242
|
abortSignal,
|
|
193
|
-
failedResponseHandler:
|
|
194
|
-
successfulResponseHandler:
|
|
243
|
+
failedResponseHandler: createStatusCodeErrorResponseHandler(),
|
|
244
|
+
successfulResponseHandler: createBinaryResponseHandler(),
|
|
195
245
|
fetch: this.config.fetch
|
|
196
246
|
});
|
|
197
247
|
return {
|
|
@@ -241,11 +291,11 @@ var BlackForestLabsImageModel = class {
|
|
|
241
291
|
url.searchParams.set("id", requestId);
|
|
242
292
|
}
|
|
243
293
|
for (let i = 0; i < maxPollAttempts; i++) {
|
|
244
|
-
const { value } = await
|
|
294
|
+
const { value } = await getFromApi({
|
|
245
295
|
url: url.toString(),
|
|
246
296
|
headers,
|
|
247
297
|
failedResponseHandler: bflFailedResponseHandler,
|
|
248
|
-
successfulResponseHandler:
|
|
298
|
+
successfulResponseHandler: createJsonResponseHandler(bflPollSchema),
|
|
249
299
|
abortSignal,
|
|
250
300
|
fetch: this.config.fetch
|
|
251
301
|
});
|
|
@@ -267,51 +317,11 @@ var BlackForestLabsImageModel = class {
|
|
|
267
317
|
if (status === "Error" || status === "Failed") {
|
|
268
318
|
throw new Error("Black Forest Labs generation failed.");
|
|
269
319
|
}
|
|
270
|
-
await
|
|
320
|
+
await delay(pollIntervalMillis);
|
|
271
321
|
}
|
|
272
322
|
throw new Error("Black Forest Labs generation timed out.");
|
|
273
323
|
}
|
|
274
324
|
};
|
|
275
|
-
var blackForestLabsImageModelOptionsSchema = (0, import_provider_utils.lazySchema)(
|
|
276
|
-
() => (0, import_provider_utils.zodSchema)(
|
|
277
|
-
import_v4.z.object({
|
|
278
|
-
imagePrompt: import_v4.z.string().optional(),
|
|
279
|
-
imagePromptStrength: import_v4.z.number().min(0).max(1).optional(),
|
|
280
|
-
/** @deprecated use prompt.images instead */
|
|
281
|
-
inputImage: import_v4.z.string().optional(),
|
|
282
|
-
/** @deprecated use prompt.images instead */
|
|
283
|
-
inputImage2: import_v4.z.string().optional(),
|
|
284
|
-
/** @deprecated use prompt.images instead */
|
|
285
|
-
inputImage3: import_v4.z.string().optional(),
|
|
286
|
-
/** @deprecated use prompt.images instead */
|
|
287
|
-
inputImage4: import_v4.z.string().optional(),
|
|
288
|
-
/** @deprecated use prompt.images instead */
|
|
289
|
-
inputImage5: import_v4.z.string().optional(),
|
|
290
|
-
/** @deprecated use prompt.images instead */
|
|
291
|
-
inputImage6: import_v4.z.string().optional(),
|
|
292
|
-
/** @deprecated use prompt.images instead */
|
|
293
|
-
inputImage7: import_v4.z.string().optional(),
|
|
294
|
-
/** @deprecated use prompt.images instead */
|
|
295
|
-
inputImage8: import_v4.z.string().optional(),
|
|
296
|
-
/** @deprecated use prompt.images instead */
|
|
297
|
-
inputImage9: import_v4.z.string().optional(),
|
|
298
|
-
/** @deprecated use prompt.images instead */
|
|
299
|
-
inputImage10: import_v4.z.string().optional(),
|
|
300
|
-
steps: import_v4.z.number().int().positive().optional(),
|
|
301
|
-
guidance: import_v4.z.number().min(0).optional(),
|
|
302
|
-
width: import_v4.z.number().int().min(256).max(1920).optional(),
|
|
303
|
-
height: import_v4.z.number().int().min(256).max(1920).optional(),
|
|
304
|
-
outputFormat: import_v4.z.enum(["jpeg", "png"]).optional(),
|
|
305
|
-
promptUpsampling: import_v4.z.boolean().optional(),
|
|
306
|
-
raw: import_v4.z.boolean().optional(),
|
|
307
|
-
safetyTolerance: import_v4.z.number().int().min(0).max(6).optional(),
|
|
308
|
-
webhookSecret: import_v4.z.string().optional(),
|
|
309
|
-
webhookUrl: import_v4.z.url().optional(),
|
|
310
|
-
pollIntervalMillis: import_v4.z.number().int().positive().optional(),
|
|
311
|
-
pollTimeoutMillis: import_v4.z.number().int().positive().optional()
|
|
312
|
-
})
|
|
313
|
-
)
|
|
314
|
-
);
|
|
315
325
|
function convertSizeToAspectRatio(size) {
|
|
316
326
|
const [wStr, hStr] = size.split("x");
|
|
317
327
|
const width = Number(wStr);
|
|
@@ -332,30 +342,30 @@ function gcd(a, b) {
|
|
|
332
342
|
}
|
|
333
343
|
return x;
|
|
334
344
|
}
|
|
335
|
-
var bflSubmitSchema =
|
|
336
|
-
id:
|
|
337
|
-
polling_url:
|
|
338
|
-
cost:
|
|
339
|
-
input_mp:
|
|
340
|
-
output_mp:
|
|
345
|
+
var bflSubmitSchema = z2.object({
|
|
346
|
+
id: z2.string(),
|
|
347
|
+
polling_url: z2.url(),
|
|
348
|
+
cost: z2.number().nullish(),
|
|
349
|
+
input_mp: z2.number().nullish(),
|
|
350
|
+
output_mp: z2.number().nullish()
|
|
341
351
|
});
|
|
342
|
-
var bflStatus =
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
352
|
+
var bflStatus = z2.union([
|
|
353
|
+
z2.literal("Pending"),
|
|
354
|
+
z2.literal("Ready"),
|
|
355
|
+
z2.literal("Error"),
|
|
356
|
+
z2.literal("Failed"),
|
|
357
|
+
z2.literal("Request Moderated")
|
|
348
358
|
]);
|
|
349
|
-
var bflPollSchema =
|
|
359
|
+
var bflPollSchema = z2.object({
|
|
350
360
|
status: bflStatus.optional(),
|
|
351
361
|
state: bflStatus.optional(),
|
|
352
|
-
details:
|
|
353
|
-
result:
|
|
354
|
-
sample:
|
|
355
|
-
seed:
|
|
356
|
-
start_time:
|
|
357
|
-
end_time:
|
|
358
|
-
duration:
|
|
362
|
+
details: z2.unknown().optional(),
|
|
363
|
+
result: z2.object({
|
|
364
|
+
sample: z2.url(),
|
|
365
|
+
seed: z2.number().optional(),
|
|
366
|
+
start_time: z2.number().optional(),
|
|
367
|
+
end_time: z2.number().optional(),
|
|
368
|
+
duration: z2.number().optional()
|
|
359
369
|
}).nullish()
|
|
360
370
|
}).refine((v) => v.status != null || v.state != null, {
|
|
361
371
|
message: "Missing status in Black Forest Labs poll response"
|
|
@@ -366,11 +376,11 @@ var bflPollSchema = import_v4.z.object({
|
|
|
366
376
|
result: v.result
|
|
367
377
|
};
|
|
368
378
|
});
|
|
369
|
-
var bflErrorSchema =
|
|
370
|
-
message:
|
|
371
|
-
detail:
|
|
379
|
+
var bflErrorSchema = z2.object({
|
|
380
|
+
message: z2.string().optional(),
|
|
381
|
+
detail: z2.any().optional()
|
|
372
382
|
});
|
|
373
|
-
var bflFailedResponseHandler =
|
|
383
|
+
var bflFailedResponseHandler = createJsonErrorResponseHandler({
|
|
374
384
|
errorSchema: bflErrorSchema,
|
|
375
385
|
errorToMessage: (error) => {
|
|
376
386
|
var _a;
|
|
@@ -392,16 +402,16 @@ function bflErrorToMessage(error) {
|
|
|
392
402
|
}
|
|
393
403
|
|
|
394
404
|
// src/version.ts
|
|
395
|
-
var VERSION = true ? "2.0.0-beta.
|
|
405
|
+
var VERSION = true ? "2.0.0-beta.31" : "0.0.0-test";
|
|
396
406
|
|
|
397
407
|
// src/black-forest-labs-provider.ts
|
|
398
408
|
var defaultBaseURL = "https://api.bfl.ai/v1";
|
|
399
409
|
function createBlackForestLabs(options = {}) {
|
|
400
410
|
var _a;
|
|
401
|
-
const baseURL =
|
|
402
|
-
const getHeaders = () =>
|
|
411
|
+
const baseURL = withoutTrailingSlash((_a = options.baseURL) != null ? _a : defaultBaseURL);
|
|
412
|
+
const getHeaders = () => withUserAgentSuffix(
|
|
403
413
|
{
|
|
404
|
-
"x-key":
|
|
414
|
+
"x-key": loadApiKey({
|
|
405
415
|
apiKey: options.apiKey,
|
|
406
416
|
environmentVariableName: "BFL_API_KEY",
|
|
407
417
|
description: "Black Forest Labs"
|
|
@@ -419,17 +429,17 @@ function createBlackForestLabs(options = {}) {
|
|
|
419
429
|
pollTimeoutMillis: options.pollTimeoutMillis
|
|
420
430
|
});
|
|
421
431
|
const embeddingModel = (modelId) => {
|
|
422
|
-
throw new
|
|
432
|
+
throw new NoSuchModelError({
|
|
423
433
|
modelId,
|
|
424
434
|
modelType: "embeddingModel"
|
|
425
435
|
});
|
|
426
436
|
};
|
|
427
437
|
return {
|
|
428
|
-
specificationVersion: "
|
|
438
|
+
specificationVersion: "v4",
|
|
429
439
|
imageModel: createImageModel,
|
|
430
440
|
image: createImageModel,
|
|
431
441
|
languageModel: (modelId) => {
|
|
432
|
-
throw new
|
|
442
|
+
throw new NoSuchModelError({
|
|
433
443
|
modelId,
|
|
434
444
|
modelType: "languageModel"
|
|
435
445
|
});
|
|
@@ -439,10 +449,9 @@ function createBlackForestLabs(options = {}) {
|
|
|
439
449
|
};
|
|
440
450
|
}
|
|
441
451
|
var blackForestLabs = createBlackForestLabs();
|
|
442
|
-
|
|
443
|
-
0 && (module.exports = {
|
|
452
|
+
export {
|
|
444
453
|
VERSION,
|
|
445
454
|
blackForestLabs,
|
|
446
455
|
createBlackForestLabs
|
|
447
|
-
}
|
|
456
|
+
};
|
|
448
457
|
//# sourceMappingURL=index.js.map
|