@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.mjs CHANGED
@@ -2515,10 +2515,7 @@ var LLMGatewayChatCompletionBaseResponseSchema = z6.object({
2515
2515
  reasoning_tokens: z6.number()
2516
2516
  }).nullish(),
2517
2517
  total_tokens: z6.number(),
2518
- cost: z6.union([
2519
- z6.number(),
2520
- z6.object({ total_cost: z6.number() }).passthrough()
2521
- ]).optional(),
2518
+ cost: z6.union([z6.number(), z6.object({ total_cost: z6.number() }).passthrough()]).optional(),
2522
2519
  cost_details: z6.object({
2523
2520
  upstream_inference_cost: z6.number().nullish()
2524
2521
  }).nullish()
@@ -3607,30 +3604,39 @@ var LLMGatewayImageModel = class {
3607
3604
  }
3608
3605
  async doGenerate(options) {
3609
3606
  const warnings = [];
3610
- if (options.aspectRatio != null) {
3611
- warnings.push({
3612
- type: "unsupported",
3613
- feature: "aspectRatio"
3614
- });
3615
- }
3616
3607
  if (options.seed != null) {
3617
3608
  warnings.push({
3618
3609
  type: "unsupported",
3619
3610
  feature: "seed"
3620
3611
  });
3621
3612
  }
3613
+ const hasFiles = options.files != null && options.files.length > 0;
3622
3614
  const body = {
3623
3615
  model: this.modelId,
3624
3616
  prompt: options.prompt,
3625
3617
  n: options.n,
3626
3618
  response_format: "b64_json"
3627
3619
  };
3620
+ if (hasFiles) {
3621
+ body.images = options.files.map((file) => {
3622
+ var _a16;
3623
+ if (file.type === "url") {
3624
+ return { image_url: file.url };
3625
+ }
3626
+ const base64 = typeof file.data === "string" ? file.data : Buffer.from(file.data).toString("base64");
3627
+ const mediaType = (_a16 = file.mediaType) != null ? _a16 : "image/png";
3628
+ return { image_url: `data:${mediaType};base64,${base64}` };
3629
+ });
3630
+ }
3628
3631
  if (options.size != null) {
3629
3632
  body.size = options.size;
3630
3633
  }
3634
+ if (options.aspectRatio != null) {
3635
+ body.aspect_ratio = options.aspectRatio;
3636
+ }
3631
3637
  const { value: response, responseHeaders } = await postJsonToApi({
3632
3638
  url: this.config.url({
3633
- path: "/images/generations",
3639
+ path: hasFiles ? "/images/edits" : "/images/generations",
3634
3640
  modelId: this.modelId
3635
3641
  }),
3636
3642
  headers: combineHeaders(this.config.headers(), options.headers),