@ai-sdk/black-forest-labs 0.0.0-fd764a60-20260114143805

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,325 @@
1
+ # @ai-sdk/black-forest-labs
2
+
3
+ ## 0.0.0-fd764a60-20260114143805
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9fbe723]
8
+ - @ai-sdk/provider-utils@0.0.0-fd764a60-20260114143805
9
+ - @ai-sdk/provider@0.0.0-fd764a60-20260114143805
10
+
11
+ ## 1.0.5
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [34d1c8a]
16
+ - @ai-sdk/provider-utils@4.0.5
17
+
18
+ ## 1.0.4
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [d937c8f]
23
+ - @ai-sdk/provider@3.0.2
24
+ - @ai-sdk/provider-utils@4.0.4
25
+
26
+ ## 1.0.3
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [0b429d4]
31
+ - @ai-sdk/provider-utils@4.0.3
32
+
33
+ ## 1.0.2
34
+
35
+ ### Patch Changes
36
+
37
+ - 863d34f: fix: trigger release to update `@latest`
38
+ - Updated dependencies [863d34f]
39
+ - @ai-sdk/provider@3.0.1
40
+ - @ai-sdk/provider-utils@4.0.2
41
+
42
+ ## 1.0.1
43
+
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies [29264a3]
47
+ - @ai-sdk/provider-utils@4.0.1
48
+
49
+ ## 1.0.0
50
+
51
+ ### Major Changes
52
+
53
+ - 8a9f0d4: feat(black-forest-labs): initial version
54
+
55
+ ### Patch Changes
56
+
57
+ - 3922a5f: feat(provider/black-forest-labs): make polling timeout configurable
58
+ - 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3
59
+
60
+ Before
61
+
62
+ ```ts
63
+ model.textEmbeddingModel('my-model-id');
64
+ ```
65
+
66
+ After
67
+
68
+ ```ts
69
+ model.embeddingModel('my-model-id');
70
+ ```
71
+
72
+ - cd3b71c: feat (provider/black-forest-labs): include cost and megapixels in metadata
73
+ - 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
74
+ - 9061dc0: feat: image editing
75
+ - 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases
76
+ - b8e77ef: feat(provider/black-forest-labs): Add new provider options
77
+ - 666bd16: fix (provider/black-forest-labs): allow null for cost and megapixel in provider response
78
+ - Updated dependencies
79
+ - @ai-sdk/provider@3.0.0
80
+ - @ai-sdk/provider-utils@4.0.0
81
+
82
+ ## 1.0.0-beta.30
83
+
84
+ ### Patch Changes
85
+
86
+ - Updated dependencies [475189e]
87
+ - @ai-sdk/provider@3.0.0-beta.32
88
+ - @ai-sdk/provider-utils@4.0.0-beta.59
89
+
90
+ ## 1.0.0-beta.29
91
+
92
+ ### Patch Changes
93
+
94
+ - Updated dependencies [2625a04]
95
+ - @ai-sdk/provider@3.0.0-beta.31
96
+ - @ai-sdk/provider-utils@4.0.0-beta.58
97
+
98
+ ## 1.0.0-beta.28
99
+
100
+ ### Patch Changes
101
+
102
+ - Updated dependencies [cbf52cd]
103
+ - @ai-sdk/provider@3.0.0-beta.30
104
+ - @ai-sdk/provider-utils@4.0.0-beta.57
105
+
106
+ ## 1.0.0-beta.27
107
+
108
+ ### Patch Changes
109
+
110
+ - Updated dependencies [9549c9e]
111
+ - @ai-sdk/provider@3.0.0-beta.29
112
+ - @ai-sdk/provider-utils@4.0.0-beta.56
113
+
114
+ ## 1.0.0-beta.26
115
+
116
+ ### Patch Changes
117
+
118
+ - Updated dependencies [50b70d6]
119
+ - @ai-sdk/provider-utils@4.0.0-beta.55
120
+
121
+ ## 1.0.0-beta.25
122
+
123
+ ### Patch Changes
124
+
125
+ - 9061dc0: feat: image editing
126
+ - Updated dependencies [9061dc0]
127
+ - @ai-sdk/provider-utils@4.0.0-beta.54
128
+ - @ai-sdk/provider@3.0.0-beta.28
129
+
130
+ ## 1.0.0-beta.24
131
+
132
+ ### Patch Changes
133
+
134
+ - 366f50b: chore(provider): add deprecated textEmbeddingModel and textEmbedding aliases
135
+ - Updated dependencies [366f50b]
136
+ - @ai-sdk/provider@3.0.0-beta.27
137
+ - @ai-sdk/provider-utils@4.0.0-beta.53
138
+
139
+ ## 1.0.0-beta.23
140
+
141
+ ### Patch Changes
142
+
143
+ - Updated dependencies [763d04a]
144
+ - @ai-sdk/provider-utils@4.0.0-beta.52
145
+
146
+ ## 1.0.0-beta.22
147
+
148
+ ### Patch Changes
149
+
150
+ - Updated dependencies [c1efac4]
151
+ - @ai-sdk/provider-utils@4.0.0-beta.51
152
+
153
+ ## 1.0.0-beta.21
154
+
155
+ ### Patch Changes
156
+
157
+ - Updated dependencies [32223c8]
158
+ - @ai-sdk/provider-utils@4.0.0-beta.50
159
+
160
+ ## 1.0.0-beta.20
161
+
162
+ ### Patch Changes
163
+
164
+ - Updated dependencies [83e5744]
165
+ - @ai-sdk/provider-utils@4.0.0-beta.49
166
+
167
+ ## 1.0.0-beta.19
168
+
169
+ ### Patch Changes
170
+
171
+ - Updated dependencies [960ec8f]
172
+ - @ai-sdk/provider-utils@4.0.0-beta.48
173
+
174
+ ## 1.0.0-beta.18
175
+
176
+ ### Patch Changes
177
+
178
+ - Updated dependencies [e9e157f]
179
+ - @ai-sdk/provider-utils@4.0.0-beta.47
180
+
181
+ ## 1.0.0-beta.17
182
+
183
+ ### Patch Changes
184
+
185
+ - Updated dependencies [81e29ab]
186
+ - @ai-sdk/provider-utils@4.0.0-beta.46
187
+
188
+ ## 1.0.0-beta.16
189
+
190
+ ### Patch Changes
191
+
192
+ - Updated dependencies [3bd2689]
193
+ - @ai-sdk/provider@3.0.0-beta.26
194
+ - @ai-sdk/provider-utils@4.0.0-beta.45
195
+
196
+ ## 1.0.0-beta.15
197
+
198
+ ### Patch Changes
199
+
200
+ - Updated dependencies [53f3368]
201
+ - @ai-sdk/provider@3.0.0-beta.25
202
+ - @ai-sdk/provider-utils@4.0.0-beta.44
203
+
204
+ ## 1.0.0-beta.14
205
+
206
+ ### Patch Changes
207
+
208
+ - Updated dependencies [dce03c4]
209
+ - @ai-sdk/provider-utils@4.0.0-beta.43
210
+ - @ai-sdk/provider@3.0.0-beta.24
211
+
212
+ ## 1.0.0-beta.13
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [3ed5519]
217
+ - @ai-sdk/provider-utils@4.0.0-beta.42
218
+
219
+ ## 1.0.0-beta.12
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies [1bd7d32]
224
+ - @ai-sdk/provider-utils@4.0.0-beta.41
225
+ - @ai-sdk/provider@3.0.0-beta.23
226
+
227
+ ## 1.0.0-beta.11
228
+
229
+ ### Patch Changes
230
+
231
+ - Updated dependencies [544d4e8]
232
+ - @ai-sdk/provider-utils@4.0.0-beta.40
233
+ - @ai-sdk/provider@3.0.0-beta.22
234
+
235
+ ## 1.0.0-beta.10
236
+
237
+ ### Patch Changes
238
+
239
+ - Updated dependencies [954c356]
240
+ - @ai-sdk/provider-utils@4.0.0-beta.39
241
+ - @ai-sdk/provider@3.0.0-beta.21
242
+
243
+ ## 1.0.0-beta.9
244
+
245
+ ### Patch Changes
246
+
247
+ - Updated dependencies [03849b0]
248
+ - @ai-sdk/provider-utils@4.0.0-beta.38
249
+
250
+ ## 1.0.0-beta.8
251
+
252
+ ### Patch Changes
253
+
254
+ - 457318b: chore(provider,ai): switch to SharedV3Warning and unified warnings
255
+ - Updated dependencies [457318b]
256
+ - @ai-sdk/provider@3.0.0-beta.20
257
+ - @ai-sdk/provider-utils@4.0.0-beta.37
258
+
259
+ ## 1.0.0-beta.7
260
+
261
+ ### Patch Changes
262
+
263
+ - 8d9e8ad: chore(provider): remove generics from EmbeddingModelV3
264
+
265
+ Before
266
+
267
+ ```ts
268
+ model.textEmbeddingModel('my-model-id');
269
+ ```
270
+
271
+ After
272
+
273
+ ```ts
274
+ model.embeddingModel('my-model-id');
275
+ ```
276
+
277
+ - Updated dependencies [8d9e8ad]
278
+ - @ai-sdk/provider@3.0.0-beta.19
279
+ - @ai-sdk/provider-utils@4.0.0-beta.36
280
+
281
+ ## 1.0.0-beta.6
282
+
283
+ ### Patch Changes
284
+
285
+ - Updated dependencies [10d819b]
286
+ - @ai-sdk/provider@3.0.0-beta.18
287
+ - @ai-sdk/provider-utils@4.0.0-beta.35
288
+
289
+ ## 1.0.0-beta.5
290
+
291
+ ### Patch Changes
292
+
293
+ - b8e77ef: feat(provider/black-forest-labs): Add new provider options
294
+
295
+ ## 1.0.0-beta.4
296
+
297
+ ### Patch Changes
298
+
299
+ - 666bd16: fix (provider/black-forest-labs): allow null for cost and megapixel in provider response
300
+
301
+ ## 1.0.0-beta.3
302
+
303
+ ### Patch Changes
304
+
305
+ - cd3b71c: feat (provider/black-forest-labs): include cost and megapixels in metadata
306
+
307
+ ## 1.0.0-beta.2
308
+
309
+ ### Patch Changes
310
+
311
+ - Updated dependencies [db913bd]
312
+ - @ai-sdk/provider@3.0.0-beta.17
313
+ - @ai-sdk/provider-utils@4.0.0-beta.34
314
+
315
+ ## 1.0.0-beta.1
316
+
317
+ ### Patch Changes
318
+
319
+ - 3922a5f: feat(provider/black-forest-labs): make polling timeout configurable
320
+
321
+ ## 1.0.0-beta.0
322
+
323
+ ### Major Changes
324
+
325
+ - 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 };