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