@llmgateway/ai-sdk-provider 3.3.0 → 3.5.0
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/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -11
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +17 -11
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +17 -11
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2548,10 +2548,7 @@ var LLMGatewayChatCompletionBaseResponseSchema = import_v45.z.object({
|
|
|
2548
2548
|
reasoning_tokens: import_v45.z.number()
|
|
2549
2549
|
}).nullish(),
|
|
2550
2550
|
total_tokens: import_v45.z.number(),
|
|
2551
|
-
cost: import_v45.z.union([
|
|
2552
|
-
import_v45.z.number(),
|
|
2553
|
-
import_v45.z.object({ total_cost: import_v45.z.number() }).passthrough()
|
|
2554
|
-
]).optional(),
|
|
2551
|
+
cost: import_v45.z.union([import_v45.z.number(), import_v45.z.object({ total_cost: import_v45.z.number() }).passthrough()]).optional(),
|
|
2555
2552
|
cost_details: import_v45.z.object({
|
|
2556
2553
|
upstream_inference_cost: import_v45.z.number().nullish()
|
|
2557
2554
|
}).nullish()
|
|
@@ -3640,30 +3637,39 @@ var LLMGatewayImageModel = class {
|
|
|
3640
3637
|
}
|
|
3641
3638
|
async doGenerate(options) {
|
|
3642
3639
|
const warnings = [];
|
|
3643
|
-
if (options.aspectRatio != null) {
|
|
3644
|
-
warnings.push({
|
|
3645
|
-
type: "unsupported",
|
|
3646
|
-
feature: "aspectRatio"
|
|
3647
|
-
});
|
|
3648
|
-
}
|
|
3649
3640
|
if (options.seed != null) {
|
|
3650
3641
|
warnings.push({
|
|
3651
3642
|
type: "unsupported",
|
|
3652
3643
|
feature: "seed"
|
|
3653
3644
|
});
|
|
3654
3645
|
}
|
|
3646
|
+
const hasFiles = options.files != null && options.files.length > 0;
|
|
3655
3647
|
const body = {
|
|
3656
3648
|
model: this.modelId,
|
|
3657
3649
|
prompt: options.prompt,
|
|
3658
3650
|
n: options.n,
|
|
3659
3651
|
response_format: "b64_json"
|
|
3660
3652
|
};
|
|
3653
|
+
if (hasFiles) {
|
|
3654
|
+
body.images = options.files.map((file) => {
|
|
3655
|
+
var _a16;
|
|
3656
|
+
if (file.type === "url") {
|
|
3657
|
+
return { image_url: file.url };
|
|
3658
|
+
}
|
|
3659
|
+
const base64 = typeof file.data === "string" ? file.data : Buffer.from(file.data).toString("base64");
|
|
3660
|
+
const mediaType = (_a16 = file.mediaType) != null ? _a16 : "image/png";
|
|
3661
|
+
return { image_url: `data:${mediaType};base64,${base64}` };
|
|
3662
|
+
});
|
|
3663
|
+
}
|
|
3661
3664
|
if (options.size != null) {
|
|
3662
3665
|
body.size = options.size;
|
|
3663
3666
|
}
|
|
3667
|
+
if (options.aspectRatio != null) {
|
|
3668
|
+
body.aspect_ratio = options.aspectRatio;
|
|
3669
|
+
}
|
|
3664
3670
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
3665
3671
|
url: this.config.url({
|
|
3666
|
-
path: "/images/generations",
|
|
3672
|
+
path: hasFiles ? "/images/edits" : "/images/generations",
|
|
3667
3673
|
modelId: this.modelId
|
|
3668
3674
|
}),
|
|
3669
3675
|
headers: combineHeaders(this.config.headers(), options.headers),
|