@llmgateway/ai-sdk-provider 3.4.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 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()
@@ -3646,12 +3643,24 @@ var LLMGatewayImageModel = class {
3646
3643
  feature: "seed"
3647
3644
  });
3648
3645
  }
3646
+ const hasFiles = options.files != null && options.files.length > 0;
3649
3647
  const body = {
3650
3648
  model: this.modelId,
3651
3649
  prompt: options.prompt,
3652
3650
  n: options.n,
3653
3651
  response_format: "b64_json"
3654
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
+ }
3655
3664
  if (options.size != null) {
3656
3665
  body.size = options.size;
3657
3666
  }
@@ -3660,7 +3669,7 @@ var LLMGatewayImageModel = class {
3660
3669
  }
3661
3670
  const { value: response, responseHeaders } = await postJsonToApi({
3662
3671
  url: this.config.url({
3663
- path: "/images/generations",
3672
+ path: hasFiles ? "/images/edits" : "/images/generations",
3664
3673
  modelId: this.modelId
3665
3674
  }),
3666
3675
  headers: combineHeaders(this.config.headers(), options.headers),