@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.
@@ -2515,10 +2515,7 @@ var LLMGatewayChatCompletionBaseResponseSchema = import_v45.z.object({
2515
2515
  reasoning_tokens: import_v45.z.number()
2516
2516
  }).nullish(),
2517
2517
  total_tokens: import_v45.z.number(),
2518
- cost: import_v45.z.union([
2519
- import_v45.z.number(),
2520
- import_v45.z.object({ total_cost: import_v45.z.number() }).passthrough()
2521
- ]).optional(),
2518
+ cost: import_v45.z.union([import_v45.z.number(), import_v45.z.object({ total_cost: import_v45.z.number() }).passthrough()]).optional(),
2522
2519
  cost_details: import_v45.z.object({
2523
2520
  upstream_inference_cost: import_v45.z.number().nullish()
2524
2521
  }).nullish()
@@ -3572,12 +3569,24 @@ var LLMGatewayImageModel = class {
3572
3569
  feature: "seed"
3573
3570
  });
3574
3571
  }
3572
+ const hasFiles = options.files != null && options.files.length > 0;
3575
3573
  const body = {
3576
3574
  model: this.modelId,
3577
3575
  prompt: options.prompt,
3578
3576
  n: options.n,
3579
3577
  response_format: "b64_json"
3580
3578
  };
3579
+ if (hasFiles) {
3580
+ body.images = options.files.map((file) => {
3581
+ var _a16;
3582
+ if (file.type === "url") {
3583
+ return { image_url: file.url };
3584
+ }
3585
+ const base64 = typeof file.data === "string" ? file.data : Buffer.from(file.data).toString("base64");
3586
+ const mediaType = (_a16 = file.mediaType) != null ? _a16 : "image/png";
3587
+ return { image_url: `data:${mediaType};base64,${base64}` };
3588
+ });
3589
+ }
3581
3590
  if (options.size != null) {
3582
3591
  body.size = options.size;
3583
3592
  }
@@ -3586,7 +3595,7 @@ var LLMGatewayImageModel = class {
3586
3595
  }
3587
3596
  const { value: response, responseHeaders } = await postJsonToApi({
3588
3597
  url: this.config.url({
3589
- path: "/images/generations",
3598
+ path: hasFiles ? "/images/edits" : "/images/generations",
3590
3599
  modelId: this.modelId
3591
3600
  }),
3592
3601
  headers: combineHeaders(this.config.headers(), options.headers),