@openrouter/ai-sdk-provider 2.2.0 → 2.2.2
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 +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +48 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -17
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +17 -0
- package/dist/internal/index.d.ts +17 -0
- package/dist/internal/index.js +47 -16
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +47 -16
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -56,6 +56,12 @@ type IdModeration = 'moderation';
|
|
|
56
56
|
* @see https://openrouter.ai/docs/guides/features/plugins/response-healing
|
|
57
57
|
*/
|
|
58
58
|
type IdResponseHealing = 'response-healing';
|
|
59
|
+
/**
|
|
60
|
+
* Plugin identifier for auto-router model selection.
|
|
61
|
+
* Configures allowed models when using the openrouter/auto model.
|
|
62
|
+
* @see https://openrouter.ai/docs/guides/routing/routers/auto-router
|
|
63
|
+
*/
|
|
64
|
+
type IdAutoRouter = 'auto-router';
|
|
59
65
|
/**
|
|
60
66
|
* Search engine options for web search.
|
|
61
67
|
* Open enum - accepts known values or any string for forward compatibility.
|
|
@@ -147,6 +153,17 @@ type OpenRouterChatSettings = {
|
|
|
147
153
|
* @see https://openrouter.ai/docs/guides/features/plugins/response-healing
|
|
148
154
|
*/
|
|
149
155
|
id: IdResponseHealing;
|
|
156
|
+
} | {
|
|
157
|
+
/**
|
|
158
|
+
* Auto-router plugin - configures allowed models when using `openrouter/auto`.
|
|
159
|
+
*
|
|
160
|
+
* Use wildcard patterns to restrict which models the auto router can select from.
|
|
161
|
+
* When no `allowed_models` are specified, the auto router uses all supported models.
|
|
162
|
+
*
|
|
163
|
+
* @see https://openrouter.ai/docs/guides/routing/routers/auto-router
|
|
164
|
+
*/
|
|
165
|
+
id: IdAutoRouter;
|
|
166
|
+
allowed_models?: string[];
|
|
150
167
|
}>;
|
|
151
168
|
/**
|
|
152
169
|
* Built-in web search options for models that support native web search
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -56,6 +56,12 @@ type IdModeration = 'moderation';
|
|
|
56
56
|
* @see https://openrouter.ai/docs/guides/features/plugins/response-healing
|
|
57
57
|
*/
|
|
58
58
|
type IdResponseHealing = 'response-healing';
|
|
59
|
+
/**
|
|
60
|
+
* Plugin identifier for auto-router model selection.
|
|
61
|
+
* Configures allowed models when using the openrouter/auto model.
|
|
62
|
+
* @see https://openrouter.ai/docs/guides/routing/routers/auto-router
|
|
63
|
+
*/
|
|
64
|
+
type IdAutoRouter = 'auto-router';
|
|
59
65
|
/**
|
|
60
66
|
* Search engine options for web search.
|
|
61
67
|
* Open enum - accepts known values or any string for forward compatibility.
|
|
@@ -147,6 +153,17 @@ type OpenRouterChatSettings = {
|
|
|
147
153
|
* @see https://openrouter.ai/docs/guides/features/plugins/response-healing
|
|
148
154
|
*/
|
|
149
155
|
id: IdResponseHealing;
|
|
156
|
+
} | {
|
|
157
|
+
/**
|
|
158
|
+
* Auto-router plugin - configures allowed models when using `openrouter/auto`.
|
|
159
|
+
*
|
|
160
|
+
* Use wildcard patterns to restrict which models the auto router can select from.
|
|
161
|
+
* When no `allowed_models` are specified, the auto router uses all supported models.
|
|
162
|
+
*
|
|
163
|
+
* @see https://openrouter.ai/docs/guides/routing/routers/auto-router
|
|
164
|
+
*/
|
|
165
|
+
id: IdAutoRouter;
|
|
166
|
+
allowed_models?: string[];
|
|
150
167
|
}>;
|
|
151
168
|
/**
|
|
152
169
|
* Built-in web search options for models that support native web search
|
package/dist/internal/index.js
CHANGED
|
@@ -2396,23 +2396,34 @@ function isUrl({
|
|
|
2396
2396
|
}
|
|
2397
2397
|
|
|
2398
2398
|
// src/chat/file-url-utils.ts
|
|
2399
|
-
function
|
|
2400
|
-
|
|
2399
|
+
function buildFileDataUrl({
|
|
2400
|
+
data,
|
|
2401
|
+
mediaType,
|
|
2401
2402
|
defaultMediaType
|
|
2402
2403
|
}) {
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
return `data:${(_a16 = part.mediaType) != null ? _a16 : defaultMediaType};base64,${base64}`;
|
|
2404
|
+
if (data instanceof Uint8Array) {
|
|
2405
|
+
const base64 = convertUint8ArrayToBase64(data);
|
|
2406
|
+
return `data:${mediaType != null ? mediaType : defaultMediaType};base64,${base64}`;
|
|
2407
2407
|
}
|
|
2408
|
-
const
|
|
2408
|
+
const stringData = data.toString();
|
|
2409
2409
|
if (isUrl({
|
|
2410
|
-
url:
|
|
2410
|
+
url: stringData,
|
|
2411
2411
|
protocols: /* @__PURE__ */ new Set(["http:", "https:"])
|
|
2412
2412
|
})) {
|
|
2413
|
-
return
|
|
2413
|
+
return stringData;
|
|
2414
2414
|
}
|
|
2415
|
-
return
|
|
2415
|
+
return stringData.startsWith("data:") ? stringData : `data:${mediaType != null ? mediaType : defaultMediaType};base64,${stringData}`;
|
|
2416
|
+
}
|
|
2417
|
+
function getFileUrl({
|
|
2418
|
+
part,
|
|
2419
|
+
defaultMediaType
|
|
2420
|
+
}) {
|
|
2421
|
+
const data = part.data instanceof URL ? part.data.toString() : part.data;
|
|
2422
|
+
return buildFileDataUrl({
|
|
2423
|
+
data,
|
|
2424
|
+
mediaType: part.mediaType,
|
|
2425
|
+
defaultMediaType
|
|
2426
|
+
});
|
|
2416
2427
|
}
|
|
2417
2428
|
function getMediaType(dataUrl, defaultMediaType) {
|
|
2418
2429
|
var _a16;
|
|
@@ -4312,11 +4323,6 @@ var OpenRouterImageModel = class {
|
|
|
4312
4323
|
} = options;
|
|
4313
4324
|
const openrouterOptions = (providerOptions == null ? void 0 : providerOptions.openrouter) || {};
|
|
4314
4325
|
const warnings = [];
|
|
4315
|
-
if (files !== void 0 && files.length > 0) {
|
|
4316
|
-
throw new UnsupportedFunctionalityError({
|
|
4317
|
-
functionality: "image editing (files parameter)"
|
|
4318
|
-
});
|
|
4319
|
-
}
|
|
4320
4326
|
if (mask !== void 0) {
|
|
4321
4327
|
throw new UnsupportedFunctionalityError({
|
|
4322
4328
|
functionality: "image inpainting (mask parameter)"
|
|
@@ -4337,12 +4343,19 @@ var OpenRouterImageModel = class {
|
|
|
4337
4343
|
});
|
|
4338
4344
|
}
|
|
4339
4345
|
const imageConfig = aspectRatio !== void 0 ? { aspect_ratio: aspectRatio } : void 0;
|
|
4346
|
+
const hasFiles = files !== void 0 && files.length > 0;
|
|
4347
|
+
const userContent = hasFiles ? [
|
|
4348
|
+
...files.map(
|
|
4349
|
+
(file) => convertImageFileToContentPart(file)
|
|
4350
|
+
),
|
|
4351
|
+
{ type: "text", text: prompt != null ? prompt : "" }
|
|
4352
|
+
] : prompt != null ? prompt : "";
|
|
4340
4353
|
const body = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
|
|
4341
4354
|
model: this.modelId,
|
|
4342
4355
|
messages: [
|
|
4343
4356
|
{
|
|
4344
4357
|
role: "user",
|
|
4345
|
-
content:
|
|
4358
|
+
content: userContent
|
|
4346
4359
|
}
|
|
4347
4360
|
],
|
|
4348
4361
|
modalities: ["image", "text"]
|
|
@@ -4393,6 +4406,24 @@ var OpenRouterImageModel = class {
|
|
|
4393
4406
|
};
|
|
4394
4407
|
}
|
|
4395
4408
|
};
|
|
4409
|
+
var DEFAULT_IMAGE_MEDIA_TYPE = "image/png";
|
|
4410
|
+
function convertImageFileToContentPart(file) {
|
|
4411
|
+
if (file.type === "url") {
|
|
4412
|
+
return {
|
|
4413
|
+
type: "image_url",
|
|
4414
|
+
image_url: { url: file.url }
|
|
4415
|
+
};
|
|
4416
|
+
}
|
|
4417
|
+
const url = buildFileDataUrl({
|
|
4418
|
+
data: file.data,
|
|
4419
|
+
mediaType: file.mediaType,
|
|
4420
|
+
defaultMediaType: DEFAULT_IMAGE_MEDIA_TYPE
|
|
4421
|
+
});
|
|
4422
|
+
return {
|
|
4423
|
+
type: "image_url",
|
|
4424
|
+
image_url: { url }
|
|
4425
|
+
};
|
|
4426
|
+
}
|
|
4396
4427
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4397
4428
|
0 && (module.exports = {
|
|
4398
4429
|
OpenRouterChatLanguageModel,
|