@openrouter/ai-sdk-provider 2.8.1 → 2.9.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.
@@ -219,6 +219,25 @@ type OpenRouterChatSettings = {
219
219
  */
220
220
  echo_upstream_body?: boolean;
221
221
  };
222
+ /**
223
+ * Structured-output options forwarded to OpenRouter's
224
+ * `response_format.json_schema` payload.
225
+ *
226
+ * Use this to opt out of strict mode for models whose providers don't
227
+ * advertise support for it (e.g. open-source models routed through
228
+ * non-OpenAI-compatible providers). When `strict` is left unset, the
229
+ * SDK defaults to `true` for backward compatibility.
230
+ *
231
+ * Only applies when a `responseFormat` with a `schema` is provided on
232
+ * the call site. Has no effect for `json_object` or text responses.
233
+ */
234
+ structuredOutputs?: {
235
+ /**
236
+ * Whether to set `response_format.json_schema.strict` on the outbound
237
+ * request. Defaults to `true` when omitted.
238
+ */
239
+ strict?: boolean;
240
+ };
222
241
  /**
223
242
  * Provider routing preferences to control request routing behavior
224
243
  */
@@ -219,6 +219,25 @@ type OpenRouterChatSettings = {
219
219
  */
220
220
  echo_upstream_body?: boolean;
221
221
  };
222
+ /**
223
+ * Structured-output options forwarded to OpenRouter's
224
+ * `response_format.json_schema` payload.
225
+ *
226
+ * Use this to opt out of strict mode for models whose providers don't
227
+ * advertise support for it (e.g. open-source models routed through
228
+ * non-OpenAI-compatible providers). When `strict` is left unset, the
229
+ * SDK defaults to `true` for backward compatibility.
230
+ *
231
+ * Only applies when a `responseFormat` with a `schema` is provided on
232
+ * the call site. Has no effect for `json_object` or text responses.
233
+ */
234
+ structuredOutputs?: {
235
+ /**
236
+ * Whether to set `response_format.json_schema.strict` on the outbound
237
+ * request. Defaults to `true` when omitted.
238
+ */
239
+ strict?: boolean;
240
+ };
222
241
  /**
223
242
  * Provider routing preferences to control request routing behavior
224
243
  */
@@ -3454,7 +3454,7 @@ var OpenRouterChatLanguageModel = class {
3454
3454
  this.supportedUrls = {
3455
3455
  "image/*": [
3456
3456
  /^data:image\/[a-zA-Z]+;base64,/,
3457
- /^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)$/i
3457
+ /^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)(?:[?#].*)?$/i
3458
3458
  ],
3459
3459
  // 'text/*': [/^data:text\//, /^https?:\/\/.+$/],
3460
3460
  "application/*": [/^data:application\//, /^https?:\/\/.+$/]
@@ -3477,7 +3477,7 @@ var OpenRouterChatLanguageModel = class {
3477
3477
  tools,
3478
3478
  toolChoice
3479
3479
  }) {
3480
- var _a16, _b16;
3480
+ var _a16, _b16, _c, _d;
3481
3481
  const baseArgs = __spreadValues(__spreadValues({
3482
3482
  // model id:
3483
3483
  model: this.modelId,
@@ -3500,8 +3500,8 @@ var OpenRouterChatLanguageModel = class {
3500
3500
  type: "json_schema",
3501
3501
  json_schema: __spreadValues({
3502
3502
  schema: responseFormat.schema,
3503
- strict: true,
3504
- name: (_a16 = responseFormat.name) != null ? _a16 : "response"
3503
+ strict: (_b16 = (_a16 = this.settings.structuredOutputs) == null ? void 0 : _a16.strict) != null ? _b16 : true,
3504
+ name: (_c = responseFormat.name) != null ? _c : "response"
3505
3505
  }, responseFormat.description && {
3506
3506
  description: responseFormat.description
3507
3507
  })
@@ -3527,7 +3527,7 @@ var OpenRouterChatLanguageModel = class {
3527
3527
  const mappedTools = [];
3528
3528
  for (const tool of tools) {
3529
3529
  if (tool.type === "function") {
3530
- const openrouterOptions = (_b16 = tool.providerOptions) == null ? void 0 : _b16.openrouter;
3530
+ const openrouterOptions = (_d = tool.providerOptions) == null ? void 0 : _d.openrouter;
3531
3531
  const eagerInputStreaming = openrouterOptions == null ? void 0 : openrouterOptions.eager_input_streaming;
3532
3532
  mappedTools.push(__spreadValues({
3533
3533
  type: "function",
@@ -4096,7 +4096,7 @@ var OpenRouterChatLanguageModel = class {
4096
4096
  id: toolCall.id,
4097
4097
  delta: (_s = toolCallDelta.function.arguments) != null ? _s : ""
4098
4098
  });
4099
- if (((_t = toolCall.function) == null ? void 0 : _t.name) != null && ((_u = toolCall.function) == null ? void 0 : _u.arguments) != null && isParsableJson(toolCall.function.arguments)) {
4099
+ if (!toolCall.sent && ((_t = toolCall.function) == null ? void 0 : _t.name) != null && ((_u = toolCall.function) == null ? void 0 : _u.arguments) != null && isParsableJson(toolCall.function.arguments)) {
4100
4100
  controller.enqueue({
4101
4101
  type: "tool-input-end",
4102
4102
  id: toolCall.id
@@ -4402,7 +4402,7 @@ var OpenRouterCompletionLanguageModel = class {
4402
4402
  this.supportedUrls = {
4403
4403
  "image/*": [
4404
4404
  /^data:image\/[a-zA-Z]+;base64,/,
4405
- /^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)$/i
4405
+ /^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)(?:[?#].*)?$/i
4406
4406
  ],
4407
4407
  "text/*": [/^data:text\//, /^https?:\/\/.+$/],
4408
4408
  "application/*": [/^data:application\//, /^https?:\/\/.+$/]