@openrouter/ai-sdk-provider 2.9.1 → 2.10.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.d.mts CHANGED
@@ -674,7 +674,7 @@ declare class OpenRouterImageModel implements ImageModelV3 {
674
674
  readonly provider = "openrouter";
675
675
  readonly modelId: OpenRouterImageModelId;
676
676
  readonly settings: OpenRouterImageSettings;
677
- readonly maxImagesPerCall = 1;
677
+ readonly maxImagesPerCall = 10;
678
678
  private readonly config;
679
679
  constructor(modelId: OpenRouterImageModelId, settings: OpenRouterImageSettings, config: OpenRouterImageConfig);
680
680
  doGenerate(options: ImageModelV3CallOptions): Promise<{
package/dist/index.d.ts CHANGED
@@ -674,7 +674,7 @@ declare class OpenRouterImageModel implements ImageModelV3 {
674
674
  readonly provider = "openrouter";
675
675
  readonly modelId: OpenRouterImageModelId;
676
676
  readonly settings: OpenRouterImageSettings;
677
- readonly maxImagesPerCall = 1;
677
+ readonly maxImagesPerCall = 10;
678
678
  private readonly config;
679
679
  constructor(modelId: OpenRouterImageModelId, settings: OpenRouterImageSettings, config: OpenRouterImageConfig);
680
680
  doGenerate(options: ImageModelV3CallOptions): Promise<{
package/dist/index.js CHANGED
@@ -4892,26 +4892,10 @@ var OpenRouter = class {
4892
4892
  // src/image/schemas.ts
4893
4893
  var import_v49 = require("zod/v4");
4894
4894
  var OpenRouterImageResponseSchema = import_v49.z.object({
4895
- id: import_v49.z.string().optional(),
4896
- object: import_v49.z.string().optional(),
4897
4895
  created: import_v49.z.number().optional(),
4898
- model: import_v49.z.string(),
4899
- choices: import_v49.z.array(
4896
+ data: import_v49.z.array(
4900
4897
  import_v49.z.object({
4901
- index: import_v49.z.number(),
4902
- message: import_v49.z.object({
4903
- role: import_v49.z.string(),
4904
- content: import_v49.z.string().nullable().optional(),
4905
- images: import_v49.z.array(
4906
- import_v49.z.object({
4907
- type: import_v49.z.literal("image_url"),
4908
- image_url: import_v49.z.object({
4909
- url: import_v49.z.string()
4910
- })
4911
- }).passthrough()
4912
- ).optional()
4913
- }).passthrough(),
4914
- finish_reason: import_v49.z.string().nullable().optional()
4898
+ b64_json: import_v49.z.string()
4915
4899
  }).passthrough()
4916
4900
  ),
4917
4901
  usage: import_v49.z.object({
@@ -4926,13 +4910,12 @@ var OpenRouterImageModel = class {
4926
4910
  constructor(modelId, settings, config) {
4927
4911
  this.specificationVersion = "v3";
4928
4912
  this.provider = "openrouter";
4929
- this.maxImagesPerCall = 1;
4913
+ this.maxImagesPerCall = 10;
4930
4914
  this.modelId = modelId;
4931
4915
  this.settings = settings;
4932
4916
  this.config = config;
4933
4917
  }
4934
4918
  async doGenerate(options) {
4935
- var _a16;
4936
4919
  const {
4937
4920
  prompt,
4938
4921
  n,
@@ -4952,43 +4935,19 @@ var OpenRouterImageModel = class {
4952
4935
  functionality: "image inpainting (mask parameter)"
4953
4936
  });
4954
4937
  }
4955
- if (n > 1) {
4956
- warnings.push({
4957
- type: "unsupported",
4958
- feature: "n > 1",
4959
- details: `OpenRouter image generation returns 1 image per call. Requested ${n} images.`
4960
- });
4961
- }
4962
- if (size !== void 0) {
4963
- warnings.push({
4964
- type: "unsupported",
4965
- feature: "size",
4966
- details: "Use aspectRatio instead. Size parameter is not supported by OpenRouter image generation."
4967
- });
4968
- }
4969
- const imageConfig = aspectRatio !== void 0 ? { aspect_ratio: aspectRatio } : void 0;
4970
4938
  const hasFiles = files !== void 0 && files.length > 0;
4971
- const userContent = hasFiles ? [
4972
- ...files.map(
4973
- (file) => convertImageFileToContentPart(file)
4974
- ),
4975
- { type: "text", text: prompt != null ? prompt : "" }
4976
- ] : prompt != null ? prompt : "";
4977
- const body = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
4939
+ const inputReferences = hasFiles ? files.map((file) => convertFileToInputReference(file)) : void 0;
4940
+ const body = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
4978
4941
  model: this.modelId,
4979
- messages: [
4980
- {
4981
- role: "user",
4982
- content: userContent
4983
- }
4984
- ],
4985
- modalities: ["image", "text"]
4986
- }, imageConfig !== void 0 && { image_config: imageConfig }), seed !== void 0 && { seed }), this.settings.user !== void 0 && { user: this.settings.user }), this.settings.provider !== void 0 && {
4942
+ prompt: prompt != null ? prompt : ""
4943
+ }, n !== void 0 && { n }), size !== void 0 && { size }), aspectRatio !== void 0 && { aspect_ratio: aspectRatio }), seed !== void 0 && { seed }), inputReferences !== void 0 && {
4944
+ input_references: inputReferences
4945
+ }), this.settings.user !== void 0 && { user: this.settings.user }), this.settings.provider !== void 0 && {
4987
4946
  provider: this.settings.provider
4988
4947
  }), this.config.extraBody), this.settings.extraBody), openrouterOptions);
4989
4948
  const { value: responseValue, responseHeaders } = await postJsonToApi({
4990
4949
  url: this.config.url({
4991
- path: "/chat/completions",
4950
+ path: "/images",
4992
4951
  modelId: this.modelId
4993
4952
  }),
4994
4953
  headers: combineHeaders(this.config.headers(), headers),
@@ -5000,19 +4959,12 @@ var OpenRouterImageModel = class {
5000
4959
  abortSignal,
5001
4960
  fetch: this.config.fetch
5002
4961
  });
5003
- const choice = responseValue.choices[0];
5004
- if (!choice) {
4962
+ if (!responseValue.data || responseValue.data.length === 0) {
5005
4963
  throw new NoContentGeneratedError({
5006
- message: "No choice in response"
4964
+ message: "No images in response"
5007
4965
  });
5008
4966
  }
5009
- const images = [];
5010
- if ((_a16 = choice.message) == null ? void 0 : _a16.images) {
5011
- for (const image of choice.message.images) {
5012
- const dataUrl = image.image_url.url;
5013
- images.push(getBase64FromDataUrl(dataUrl));
5014
- }
5015
- }
4967
+ const images = responseValue.data.map((item) => item.b64_json);
5016
4968
  const usage = responseValue.usage ? {
5017
4969
  inputTokens: responseValue.usage.prompt_tokens,
5018
4970
  outputTokens: responseValue.usage.completion_tokens,
@@ -5023,7 +4975,7 @@ var OpenRouterImageModel = class {
5023
4975
  warnings,
5024
4976
  response: {
5025
4977
  timestamp: /* @__PURE__ */ new Date(),
5026
- modelId: responseValue.model,
4978
+ modelId: this.modelId,
5027
4979
  headers: responseHeaders
5028
4980
  },
5029
4981
  usage
@@ -5031,7 +4983,7 @@ var OpenRouterImageModel = class {
5031
4983
  }
5032
4984
  };
5033
4985
  var DEFAULT_IMAGE_MEDIA_TYPE = "image/png";
5034
- function convertImageFileToContentPart(file) {
4986
+ function convertFileToInputReference(file) {
5035
4987
  if (file.type === "url") {
5036
4988
  return {
5037
4989
  type: "image_url",
@@ -5101,7 +5053,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
5101
5053
  }
5102
5054
 
5103
5055
  // src/version.ts
5104
- var VERSION2 = false ? "0.0.0-test" : "2.9.1";
5056
+ var VERSION2 = false ? "0.0.0-test" : "2.10.0";
5105
5057
 
5106
5058
  // src/video/schemas.ts
5107
5059
  var import_v411 = require("zod/v4");