@ai-sdk/black-forest-labs 0.0.0-1c33ba03-20260114162300

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 ADDED
@@ -0,0 +1,332 @@
1
+ # @ai-sdk/black-forest-labs
2
+
3
+ ## 0.0.0-1c33ba03-20260114162300
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [261c011]
8
+ - @ai-sdk/provider-utils@0.0.0-1c33ba03-20260114162300
9
+
10
+ ## 1.0.6
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [1b11dcb]
15
+ - @ai-sdk/provider-utils@4.0.6
16
+ - @ai-sdk/provider@3.0.3
17
+
18
+ ## 1.0.5
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [34d1c8a]
23
+ - @ai-sdk/provider-utils@4.0.5
24
+
25
+ ## 1.0.4
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [d937c8f]
30
+ - @ai-sdk/provider@3.0.2
31
+ - @ai-sdk/provider-utils@4.0.4
32
+
33
+ ## 1.0.3
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [0b429d4]
38
+ - @ai-sdk/provider-utils@4.0.3
39
+
40
+ ## 1.0.2
41
+
42
+ ### Patch Changes
43
+
44
+ - 863d34f: fix: trigger release to update `@latest`
45
+ - Updated dependencies [863d34f]
46
+ - @ai-sdk/provider@3.0.1
47
+ - @ai-sdk/provider-utils@4.0.2
48
+
49
+ ## 1.0.1
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [29264a3]
54
+ - @ai-sdk/provider-utils@4.0.1
55
+
56
+ ## 1.0.0
57
+
58
+ ### Major Changes
59
+
60
+ - 8a9f0d4: feat(black-forest-labs): initial version
61
+
62
+ ### Patch Changes
63
+
64
+ - 3922a5f: feat(provider/black-forest-labs): make polling timeout configurable
65
+ - 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3
66
+
67
+ Before
68
+
69
+ ```ts
70
+ model.textEmbeddingModel('my-model-id');
71
+ ```
72
+
73
+ After
74
+
75
+ ```ts
76
+ model.embeddingModel('my-model-id');
77
+ ```
78
+
79
+ - cd3b71c: feat (provider/black-forest-labs): include cost and megapixels in metadata
80
+ - 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
81
+ - 9061dc0: feat: image editing
82
+ - 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases
83
+ - b8e77ef: feat(provider/black-forest-labs): Add new provider options
84
+ - 666bd16: fix (provider/black-forest-labs): allow null for cost and megapixel in provider response
85
+ - Updated dependencies
86
+ - @ai-sdk/provider@3.0.0
87
+ - @ai-sdk/provider-utils@4.0.0
88
+
89
+ ## 1.0.0-beta.30
90
+
91
+ ### Patch Changes
92
+
93
+ - Updated dependencies [475189e]
94
+ - @ai-sdk/provider@3.0.0-beta.32
95
+ - @ai-sdk/provider-utils@4.0.0-beta.59
96
+
97
+ ## 1.0.0-beta.29
98
+
99
+ ### Patch Changes
100
+
101
+ - Updated dependencies [2625a04]
102
+ - @ai-sdk/provider@3.0.0-beta.31
103
+ - @ai-sdk/provider-utils@4.0.0-beta.58
104
+
105
+ ## 1.0.0-beta.28
106
+
107
+ ### Patch Changes
108
+
109
+ - Updated dependencies [cbf52cd]
110
+ - @ai-sdk/provider@3.0.0-beta.30
111
+ - @ai-sdk/provider-utils@4.0.0-beta.57
112
+
113
+ ## 1.0.0-beta.27
114
+
115
+ ### Patch Changes
116
+
117
+ - Updated dependencies [9549c9e]
118
+ - @ai-sdk/provider@3.0.0-beta.29
119
+ - @ai-sdk/provider-utils@4.0.0-beta.56
120
+
121
+ ## 1.0.0-beta.26
122
+
123
+ ### Patch Changes
124
+
125
+ - Updated dependencies [50b70d6]
126
+ - @ai-sdk/provider-utils@4.0.0-beta.55
127
+
128
+ ## 1.0.0-beta.25
129
+
130
+ ### Patch Changes
131
+
132
+ - 9061dc0: feat: image editing
133
+ - Updated dependencies [9061dc0]
134
+ - @ai-sdk/provider-utils@4.0.0-beta.54
135
+ - @ai-sdk/provider@3.0.0-beta.28
136
+
137
+ ## 1.0.0-beta.24
138
+
139
+ ### Patch Changes
140
+
141
+ - 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases
142
+ - Updated dependencies [366f50b]
143
+ - @ai-sdk/provider@3.0.0-beta.27
144
+ - @ai-sdk/provider-utils@4.0.0-beta.53
145
+
146
+ ## 1.0.0-beta.23
147
+
148
+ ### Patch Changes
149
+
150
+ - Updated dependencies [763d04a]
151
+ - @ai-sdk/provider-utils@4.0.0-beta.52
152
+
153
+ ## 1.0.0-beta.22
154
+
155
+ ### Patch Changes
156
+
157
+ - Updated dependencies [c1efac4]
158
+ - @ai-sdk/provider-utils@4.0.0-beta.51
159
+
160
+ ## 1.0.0-beta.21
161
+
162
+ ### Patch Changes
163
+
164
+ - Updated dependencies [32223c8]
165
+ - @ai-sdk/provider-utils@4.0.0-beta.50
166
+
167
+ ## 1.0.0-beta.20
168
+
169
+ ### Patch Changes
170
+
171
+ - Updated dependencies [83e5744]
172
+ - @ai-sdk/provider-utils@4.0.0-beta.49
173
+
174
+ ## 1.0.0-beta.19
175
+
176
+ ### Patch Changes
177
+
178
+ - Updated dependencies [960ec8f]
179
+ - @ai-sdk/provider-utils@4.0.0-beta.48
180
+
181
+ ## 1.0.0-beta.18
182
+
183
+ ### Patch Changes
184
+
185
+ - Updated dependencies [e9e157f]
186
+ - @ai-sdk/provider-utils@4.0.0-beta.47
187
+
188
+ ## 1.0.0-beta.17
189
+
190
+ ### Patch Changes
191
+
192
+ - Updated dependencies [81e29ab]
193
+ - @ai-sdk/provider-utils@4.0.0-beta.46
194
+
195
+ ## 1.0.0-beta.16
196
+
197
+ ### Patch Changes
198
+
199
+ - Updated dependencies [3bd2689]
200
+ - @ai-sdk/provider@3.0.0-beta.26
201
+ - @ai-sdk/provider-utils@4.0.0-beta.45
202
+
203
+ ## 1.0.0-beta.15
204
+
205
+ ### Patch Changes
206
+
207
+ - Updated dependencies [53f3368]
208
+ - @ai-sdk/provider@3.0.0-beta.25
209
+ - @ai-sdk/provider-utils@4.0.0-beta.44
210
+
211
+ ## 1.0.0-beta.14
212
+
213
+ ### Patch Changes
214
+
215
+ - Updated dependencies [dce03c4]
216
+ - @ai-sdk/provider-utils@4.0.0-beta.43
217
+ - @ai-sdk/provider@3.0.0-beta.24
218
+
219
+ ## 1.0.0-beta.13
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies [3ed5519]
224
+ - @ai-sdk/provider-utils@4.0.0-beta.42
225
+
226
+ ## 1.0.0-beta.12
227
+
228
+ ### Patch Changes
229
+
230
+ - Updated dependencies [1bd7d32]
231
+ - @ai-sdk/provider-utils@4.0.0-beta.41
232
+ - @ai-sdk/provider@3.0.0-beta.23
233
+
234
+ ## 1.0.0-beta.11
235
+
236
+ ### Patch Changes
237
+
238
+ - Updated dependencies [544d4e8]
239
+ - @ai-sdk/provider-utils@4.0.0-beta.40
240
+ - @ai-sdk/provider@3.0.0-beta.22
241
+
242
+ ## 1.0.0-beta.10
243
+
244
+ ### Patch Changes
245
+
246
+ - Updated dependencies [954c356]
247
+ - @ai-sdk/provider-utils@4.0.0-beta.39
248
+ - @ai-sdk/provider@3.0.0-beta.21
249
+
250
+ ## 1.0.0-beta.9
251
+
252
+ ### Patch Changes
253
+
254
+ - Updated dependencies [03849b0]
255
+ - @ai-sdk/provider-utils@4.0.0-beta.38
256
+
257
+ ## 1.0.0-beta.8
258
+
259
+ ### Patch Changes
260
+
261
+ - 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
262
+ - Updated dependencies [457318b]
263
+ - @ai-sdk/provider@3.0.0-beta.20
264
+ - @ai-sdk/provider-utils@4.0.0-beta.37
265
+
266
+ ## 1.0.0-beta.7
267
+
268
+ ### Patch Changes
269
+
270
+ - 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3
271
+
272
+ Before
273
+
274
+ ```ts
275
+ model.textEmbeddingModel('my-model-id');
276
+ ```
277
+
278
+ After
279
+
280
+ ```ts
281
+ model.embeddingModel('my-model-id');
282
+ ```
283
+
284
+ - Updated dependencies [8d9e8ad]
285
+ - @ai-sdk/provider@3.0.0-beta.19
286
+ - @ai-sdk/provider-utils@4.0.0-beta.36
287
+
288
+ ## 1.0.0-beta.6
289
+
290
+ ### Patch Changes
291
+
292
+ - Updated dependencies [10d819b]
293
+ - @ai-sdk/provider@3.0.0-beta.18
294
+ - @ai-sdk/provider-utils@4.0.0-beta.35
295
+
296
+ ## 1.0.0-beta.5
297
+
298
+ ### Patch Changes
299
+
300
+ - b8e77ef: feat(provider/black-forest-labs): Add new provider options
301
+
302
+ ## 1.0.0-beta.4
303
+
304
+ ### Patch Changes
305
+
306
+ - 666bd16: fix (provider/black-forest-labs): allow null for cost and megapixel in provider response
307
+
308
+ ## 1.0.0-beta.3
309
+
310
+ ### Patch Changes
311
+
312
+ - cd3b71c: feat (provider/black-forest-labs): include cost and megapixels in metadata
313
+
314
+ ## 1.0.0-beta.2
315
+
316
+ ### Patch Changes
317
+
318
+ - Updated dependencies [db913bd]
319
+ - @ai-sdk/provider@3.0.0-beta.17
320
+ - @ai-sdk/provider-utils@4.0.0-beta.34
321
+
322
+ ## 1.0.0-beta.1
323
+
324
+ ### Patch Changes
325
+
326
+ - 3922a5f: feat(provider/black-forest-labs): make polling timeout configurable
327
+
328
+ ## 1.0.0-beta.0
329
+
330
+ ### Major Changes
331
+
332
+ - 8a9f0d4: feat(black-forest-labs): initial version
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Vercel, Inc.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # AI SDK - Black Forest Labs Provider
2
+
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
+
5
+ ## Setup
6
+
7
+ The Black Forest Labs provider is available in the `@ai-sdk/black-forest-labs` module. You can install it with
8
+
9
+ ```bash
10
+ pnpm add @ai-sdk/black-forest-labs
11
+ ```
12
+
13
+ ## Provider Instance
14
+
15
+ You can import the default provider instance `blackForestLabs` from `@ai-sdk/black-forest-labs`:
16
+
17
+ ```ts
18
+ import { blackForestLabs } from '@ai-sdk/black-forest-labs';
19
+ ```
20
+
21
+ ## Image Generation Example
22
+
23
+ ```ts
24
+ import fs from 'node:fs';
25
+ import { blackForestLabs } from '@ai-sdk/black-forest-labs';
26
+ import { generateImage } from 'ai';
27
+
28
+ const { image } = await generateImage({
29
+ model: blackForestLabs.image('flux-pro-1.1'),
30
+ prompt: 'A cat wearing a intricate robe',
31
+ });
32
+
33
+ const filename = `image-${Date.now()}.png`;
34
+ fs.writeFileSync(filename, image.uint8Array);
35
+ console.log(`Image saved to ${filename}`);
36
+ ```
37
+
38
+ ## Additional Options
39
+
40
+ If you want to pass additional inputs to the model besides the prompt, use the `providerOptions.blackForestLabs` property:
41
+
42
+ ```ts
43
+ import {
44
+ blackForestLabs,
45
+ type BlackForestLabsImageProviderOptions,
46
+ } from '@ai-sdk/black-forest-labs';
47
+ import { generateImage } from 'ai';
48
+
49
+ const { image } = await generateImage({
50
+ model: blackForestLabs.image('flux-pro-1.1'),
51
+ prompt: 'A cat wearing an intricate robe',
52
+ aspectRatio: '16:9',
53
+ providerOptions: {
54
+ blackForestLabs: {
55
+ outputFormat: 'png',
56
+ } satisfies BlackForestLabsImageProviderOptions,
57
+ },
58
+ });
59
+ ```
60
+
61
+ ## Configuring Base URL
62
+
63
+ By default, the provider uses `https://api.bfl.ai/v1`. You can override this to use regional or legacy endpoints:
64
+
65
+ ```ts
66
+ import { createBlackForestLabs } from '@ai-sdk/black-forest-labs';
67
+
68
+ const blackForestLabs = createBlackForestLabs({
69
+ baseURL: 'https://api.eu.bfl.ai/v1',
70
+ apiKey: process.env.BFL_API_KEY,
71
+ });
72
+ ```
73
+
74
+ ## Configuring Polling
75
+
76
+ You can customize how often the client polls for image completion and how long it waits before timing out:
77
+
78
+ ```ts
79
+ import { createBlackForestLabs } from '@ai-sdk/black-forest-labs';
80
+
81
+ const blackForestLabs = createBlackForestLabs({
82
+ apiKey: process.env.BFL_API_KEY,
83
+ // Poll every 500ms, timeout after 5 minutes
84
+ pollIntervalMillis: 500,
85
+ pollTimeoutMillis: 5 * 60_000,
86
+ });
87
+ ```
88
+
89
+ You can also override these polling settings per request via `providerOptions.blackForestLabs`:
90
+
91
+ ```ts
92
+ import { blackForestLabs } from '@ai-sdk/black-forest-labs';
93
+ import { generateImage } from 'ai';
94
+
95
+ const { image } = await generateImage({
96
+ model: blackForestLabs.image('flux-pro-1.1'),
97
+ prompt: 'A cat wearing an intricate robe',
98
+ providerOptions: {
99
+ blackForestLabs: {
100
+ pollIntervalMillis: 250,
101
+ pollTimeoutMillis: 30_000,
102
+ },
103
+ },
104
+ });
105
+ ```
106
+
107
+ ## Documentation
108
+
109
+ See the [Black Forest Labs provider](https://ai-sdk.dev/providers/ai-sdk-providers/black-forest-labs) for more information.
@@ -0,0 +1,82 @@
1
+ import { ProviderV3, ImageModelV3 } from '@ai-sdk/provider';
2
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
+ import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
4
+
5
+ type BlackForestLabsImageModelId = 'flux-kontext-pro' | 'flux-kontext-max' | 'flux-pro-1.1-ultra' | 'flux-pro-1.1' | 'flux-pro-1.0-fill' | (string & {});
6
+ type BlackForestLabsAspectRatio = `${number}:${number}`;
7
+
8
+ interface BlackForestLabsProviderSettings {
9
+ /**
10
+ Black Forest Labs API key. Default value is taken from the `BFL_API_KEY` environment variable.
11
+ */
12
+ apiKey?: string;
13
+ /**
14
+ Base URL for the API calls. Defaults to `https://api.bfl.ai/v1`.
15
+ */
16
+ baseURL?: string;
17
+ /**
18
+ Custom headers to include in the requests.
19
+ */
20
+ headers?: Record<string, string>;
21
+ /**
22
+ Custom fetch implementation. You can use it as a middleware to intercept
23
+ requests, or to provide a custom fetch implementation for e.g. testing.
24
+ */
25
+ fetch?: FetchFunction;
26
+ /**
27
+ Poll interval in milliseconds between status checks. Defaults to 500ms.
28
+ */
29
+ pollIntervalMillis?: number;
30
+ /**
31
+ Overall timeout in milliseconds for polling before giving up. Defaults to 60s.
32
+ */
33
+ pollTimeoutMillis?: number;
34
+ }
35
+ interface BlackForestLabsProvider extends ProviderV3 {
36
+ /**
37
+ Creates a model for image generation.
38
+ */
39
+ image(modelId: BlackForestLabsImageModelId): ImageModelV3;
40
+ /**
41
+ Creates a model for image generation.
42
+ */
43
+ imageModel(modelId: BlackForestLabsImageModelId): ImageModelV3;
44
+ /**
45
+ * @deprecated Use `embeddingModel` instead.
46
+ */
47
+ textEmbeddingModel(modelId: string): never;
48
+ }
49
+ declare function createBlackForestLabs(options?: BlackForestLabsProviderSettings): BlackForestLabsProvider;
50
+ declare const blackForestLabs: BlackForestLabsProvider;
51
+
52
+ declare const blackForestLabsImageProviderOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
53
+ imagePrompt?: string | undefined;
54
+ imagePromptStrength?: number | undefined;
55
+ inputImage?: string | undefined;
56
+ inputImage2?: string | undefined;
57
+ inputImage3?: string | undefined;
58
+ inputImage4?: string | undefined;
59
+ inputImage5?: string | undefined;
60
+ inputImage6?: string | undefined;
61
+ inputImage7?: string | undefined;
62
+ inputImage8?: string | undefined;
63
+ inputImage9?: string | undefined;
64
+ inputImage10?: string | undefined;
65
+ steps?: number | undefined;
66
+ guidance?: number | undefined;
67
+ width?: number | undefined;
68
+ height?: number | undefined;
69
+ outputFormat?: "jpeg" | "png" | undefined;
70
+ promptUpsampling?: boolean | undefined;
71
+ raw?: boolean | undefined;
72
+ safetyTolerance?: number | undefined;
73
+ webhookSecret?: string | undefined;
74
+ webhookUrl?: string | undefined;
75
+ pollIntervalMillis?: number | undefined;
76
+ pollTimeoutMillis?: number | undefined;
77
+ }>;
78
+ type BlackForestLabsImageProviderOptions = InferSchema<typeof blackForestLabsImageProviderOptionsSchema>;
79
+
80
+ declare const VERSION: string;
81
+
82
+ export { type BlackForestLabsAspectRatio, type BlackForestLabsImageModelId, type BlackForestLabsImageProviderOptions, type BlackForestLabsProvider, type BlackForestLabsProviderSettings, VERSION, blackForestLabs, createBlackForestLabs };
@@ -0,0 +1,82 @@
1
+ import { ProviderV3, ImageModelV3 } from '@ai-sdk/provider';
2
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
+ import { FetchFunction, InferSchema } from '@ai-sdk/provider-utils';
4
+
5
+ type BlackForestLabsImageModelId = 'flux-kontext-pro' | 'flux-kontext-max' | 'flux-pro-1.1-ultra' | 'flux-pro-1.1' | 'flux-pro-1.0-fill' | (string & {});
6
+ type BlackForestLabsAspectRatio = `${number}:${number}`;
7
+
8
+ interface BlackForestLabsProviderSettings {
9
+ /**
10
+ Black Forest Labs API key. Default value is taken from the `BFL_API_KEY` environment variable.
11
+ */
12
+ apiKey?: string;
13
+ /**
14
+ Base URL for the API calls. Defaults to `https://api.bfl.ai/v1`.
15
+ */
16
+ baseURL?: string;
17
+ /**
18
+ Custom headers to include in the requests.
19
+ */
20
+ headers?: Record<string, string>;
21
+ /**
22
+ Custom fetch implementation. You can use it as a middleware to intercept
23
+ requests, or to provide a custom fetch implementation for e.g. testing.
24
+ */
25
+ fetch?: FetchFunction;
26
+ /**
27
+ Poll interval in milliseconds between status checks. Defaults to 500ms.
28
+ */
29
+ pollIntervalMillis?: number;
30
+ /**
31
+ Overall timeout in milliseconds for polling before giving up. Defaults to 60s.
32
+ */
33
+ pollTimeoutMillis?: number;
34
+ }
35
+ interface BlackForestLabsProvider extends ProviderV3 {
36
+ /**
37
+ Creates a model for image generation.
38
+ */
39
+ image(modelId: BlackForestLabsImageModelId): ImageModelV3;
40
+ /**
41
+ Creates a model for image generation.
42
+ */
43
+ imageModel(modelId: BlackForestLabsImageModelId): ImageModelV3;
44
+ /**
45
+ * @deprecated Use `embeddingModel` instead.
46
+ */
47
+ textEmbeddingModel(modelId: string): never;
48
+ }
49
+ declare function createBlackForestLabs(options?: BlackForestLabsProviderSettings): BlackForestLabsProvider;
50
+ declare const blackForestLabs: BlackForestLabsProvider;
51
+
52
+ declare const blackForestLabsImageProviderOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
53
+ imagePrompt?: string | undefined;
54
+ imagePromptStrength?: number | undefined;
55
+ inputImage?: string | undefined;
56
+ inputImage2?: string | undefined;
57
+ inputImage3?: string | undefined;
58
+ inputImage4?: string | undefined;
59
+ inputImage5?: string | undefined;
60
+ inputImage6?: string | undefined;
61
+ inputImage7?: string | undefined;
62
+ inputImage8?: string | undefined;
63
+ inputImage9?: string | undefined;
64
+ inputImage10?: string | undefined;
65
+ steps?: number | undefined;
66
+ guidance?: number | undefined;
67
+ width?: number | undefined;
68
+ height?: number | undefined;
69
+ outputFormat?: "jpeg" | "png" | undefined;
70
+ promptUpsampling?: boolean | undefined;
71
+ raw?: boolean | undefined;
72
+ safetyTolerance?: number | undefined;
73
+ webhookSecret?: string | undefined;
74
+ webhookUrl?: string | undefined;
75
+ pollIntervalMillis?: number | undefined;
76
+ pollTimeoutMillis?: number | undefined;
77
+ }>;
78
+ type BlackForestLabsImageProviderOptions = InferSchema<typeof blackForestLabsImageProviderOptionsSchema>;
79
+
80
+ declare const VERSION: string;
81
+
82
+ export { type BlackForestLabsAspectRatio, type BlackForestLabsImageModelId, type BlackForestLabsImageProviderOptions, type BlackForestLabsProvider, type BlackForestLabsProviderSettings, VERSION, blackForestLabs, createBlackForestLabs };