Skip to content

Latest commit

 

History

History
687 lines (397 loc) · 49.5 KB

CHANGELOG.md

File metadata and controls

687 lines (397 loc) · 49.5 KB

@openrouter/ai-sdk-provider

3.1.0

Minor Changes

  • #562 4020201 Thanks @robert-j-y! - Add openrouter.evaluationModel() backed by the OpenRouter Decisions API (/api/alpha/decisions), so experimental_evaluate from ai@7.0.103+ runs boolean, choice, and score questions through OpenRouter. Probabilities are mapped onto the AI SDK answer shapes with the API's two-decimal rounding declared on the result, and per-answer confidence, score legends, and cost are exposed under providerMetadata.openrouter. Model settings accept user, provider, session_id, trace, and extraBody; call-level providerOptions.openrouter is validated and merged into the request body without being able to override model, state, or questions. A new decisionsBaseURL provider setting configures the Decisions endpoint for proxies whose baseURL does not end in /v1. The ai peer dependency range is unchanged; only evaluationModel() requires ai@7.0.103+.

Patch Changes

3.0.0

Major Changes

  • #511 0c90b8b Thanks @Shreyaan! - Support Vercel AI SDK v7 as a v7-only major release.

    This is a breaking change because the provider now peers on ai@^7.0.0, requires Node.js 22 or newer, and publishes ESM-only output. The provider, language, embedding, image, and video model implementations now target the @ai-sdk/provider@4 V4 interfaces, with V4 file payloads and provider-defined tool factories.

    Consumers should upgrade to ai@7, run on Node.js 22+, and import this package from ESM. Usage accounting follows the AI SDK v7 shape: cached input tokens are exposed via usage.inputTokenDetails.cacheReadTokens, and reasoning tokens are exposed via usage.outputTokenDetails.reasoningTokens. OpenRouter-specific cost, BYOK, reasoning details, annotations, and cache-control metadata remain available under providerMetadata.openrouter.

Unreleased

Major Changes

  • feat: support Vercel AI SDK v7.

    This release line is v7-only: it peers on ai@^7.0.0, requires Node.js 22 or newer, and publishes ESM-only output. The provider now implements the @ai-sdk/provider@4 V4 provider/model interfaces across chat, completion, embedding, image, and video models.

    Usage accounting is mapped to the AI SDK v7 token detail shape: cached input tokens are available through usage.inputTokenDetails.cacheReadTokens, and reasoning tokens are available through usage.outputTokenDetails.reasoningTokens. OpenRouter-specific cost, BYOK, reasoning details, annotations, and cache-control metadata continue to be exposed through providerMetadata.openrouter.

2.10.0

Minor Changes

  • #513 384f3c8 Thanks @Robinnnnn! - Switch image generation to dedicated /api/v1/images endpoint

    Migrates OpenRouterImageModel from the legacy chat completions path (/chat/completions with modalities: ["image", "text"]) to OpenRouter's dedicated image generation endpoint (/images).

    Request changes:

    • Sends { model, prompt, n, size, aspect_ratio, seed, input_references } directly instead of wrapping in a chat messages array
    • files are mapped to input_references (array of { type: "image_url", image_url: { url } }) instead of inline message content parts
    • aspectRatio maps to aspect_ratio (was image_config.aspect_ratio)
    • size and n are now passed through (previously emitted warnings)

    Response changes:

    • Parses { created, data: [{ b64_json }], usage } instead of { choices: [{ message: { images } }] }
    • maxImagesPerCall updated from 1 to 10 (the new endpoint supports batch generation)

2.9.1

Patch Changes

  • #506 e9cff3a Thanks @robert-j-y! - Send content: null instead of content: "" for assistant messages that contain only tool calls. Fixes AWS Bedrock Nova rejecting requests with "The text field in the ContentBlock object is blank."

2.9.0

Minor Changes

  • #486 82e8014 Thanks @robert-j-y! - Add structuredOutputs.strict setting to opt out of response_format.json_schema.strict (issue #483).

    Previously the SDK hardcoded strict: true whenever a JSON schema response format was used, which made it impossible to route requests to providers that don't advertise support for strict json_schema. Models like moonshotai/kimi-k2.6 (routed through Parasail/Venice/Io Net) returned HTTP 404 "No endpoints available matching your guardrail restrictions and data policy" because the strict flag eliminated every eligible endpoint.

    Users can now opt out per-model:

    const model = openrouter.chat("moonshotai/kimi-k2.6", {
      structuredOutputs: { strict: false },
    });

    The default remains strict: true for backward compatibility.

Patch Changes

  • #485 bf664b1 Thanks @robert-j-y! - Fix supportedUrls['image/*'] regex to accept image URLs with query strings or fragments (e.g. https://cdn.example.com/photo.png?height=200, .../photo.webp#frag). Previously the $ anchor on the extension caused such URLs to be treated as unsupported, forcing the AI SDK runtime to download and base64-inline them, which bloated conversation history and inflated token usage.

  • #489 bb2d4cb Thanks @0age! - fix: stop emitting duplicate tool-call events when a trailing-whitespace argument delta arrives after a complete tool call

    In the streaming chat handler, the merge-into-existing-tool-call path enqueues a tool-call stream event whenever the accumulated function.arguments is parsable JSON. Because JSON.parse accepts trailing whitespace, any subsequent argument delta for the same tool-call index (e.g. a stray space, newline, or closing-token chunk) leaves the arguments parsable and would re-trigger the emit, producing a second tool-call event with the same toolCallId. Downstream tool runners (e.g. Vercel AI SDK streamText) then execute the tool twice. Observed in production with moonshotai/kimi-k2.6 via OpenRouter, where the user-visible effect was every outbound message being delivered twice.

    src/chat/index.ts:

    • Merge-path tool-call emit is now gated on !toolCall.sent, mirroring the new-path behavior. The sent flag was already being set after the first emit but was never read on this path.

    src/chat/index.test.ts:

    • Adds a regression test that streams a complete tool call followed by a trailing-whitespace-only argument delta for the same index and asserts exactly one tool-call event is emitted.

2.8.1

Patch Changes

  • #487 4588197 Thanks @louisgv! - fix: preserve empty reasoning_details arrays in multi-turn conversations

    Some providers (notably DeepSeek V4 in thinking mode) return reasoning_details: [] on turns where they produced no visible reasoning tokens. They require this empty array to be sent back in subsequent requests to maintain conversation state; omitting it causes 4xx errors on follow-up turns.

    src/chat/index.ts:

    • Stream finish event now always sets openrouterMetadata.reasoning_details, even when the accumulated array is empty (previously guarded by length > 0).
    • Both reasoning-end emit sites now always include providerMetadata.openrouter.reasoning_details, removing the length > 0 ternary that would drop the field entirely.

    src/chat/convert-to-openrouter-chat-messages.ts:

    • candidateReasoningDetails selection now uses Array.isArray(messageReasoningDetails) instead of messageReasoningDetails.length > 0 — an explicit [] is now treated as "metadata was provided" rather than "metadata was absent", and no longer falls through to findFirstReasoningDetails.
    • The top-level if (candidateReasoningDetails) guard no longer requires length > 0; an empty candidate array still triggers the dedup/signature-filter block.
    • finalReasoningDetails is now always set to uniqueDetails (the deduplicated array), never collapsed to undefined. When all entries were duplicate or signature-stripped, the empty array is preserved as a meaningful signal.
    • effectiveReasoning still requires finalReasoningDetails.length > 0 — reasoning text is never sent alongside an empty details array.

2.8.0

Minor Changes

  • #479 e381895 Thanks @abhinav-pola! - Add video generation support via provider.videoModel() implementing the Experimental_VideoModelV3 interface. Supports text-to-video and image-to-video generation with configurable aspect ratio, resolution, duration, seed, audio generation, and provider options passthrough.

2.7.0

Minor Changes

  • #465 d32823e Thanks @robert-j-y! - feat: support Anthropic eager_input_streaming parameter via tool providerOptions

    Tools can now pass eager_input_streaming: true through providerOptions.openrouter.eager_input_streaming to enable Anthropic's fine-grained tool streaming, reducing latency for large tool outputs.

Patch Changes

  • #477 918d564 Thanks @robert-j-y! - fix: stop attaching accumulated reasoning_details to reasoning-delta events (#413)

    Previously, each reasoning-delta chunk carried a full snapshot of all accumulatedReasoningDetails in its providerMetadata. For N reasoning chunks, this caused O(N²) total payload size.

    reasoning-start and reasoning-delta events no longer carry providerMetadata. The full accumulated reasoning_details are still available on reasoning-end, tool-call, and finish events (unchanged).

  • #473 839f9b0 Thanks @robert-j-y! - fix: add defensive usage fallback in streaming flush handler (#419)

    When the standard usage object has undefined totals but openrouterUsage has valid token data, the flush handler now copies values from openrouterUsage as a fallback. This ensures usage.inputTokens.total and usage.outputTokens.total are populated even when providers deliver usage data in non-standard chunk formats.

  • #388 916c4c1 Thanks @robert-j-y! - feat: add temperature and other common settings to model-level configuration

2.6.0

Minor Changes

  • #475 5b8fa40 Thanks @robert-j-y! - Add openrouter.tools.webSearch() provider-defined tool for server-side web search

    • New src/tool/web-search.ts — web search tool factory using createProviderToolFactory
    • Updated OpenRouterProvider interface with tools.webSearch property
    • Updated getArgs() to map LanguageModelV3ProviderTool to OpenRouter API server tool format (openrouter:web_search)
    • Supports optional args: maxResults, searchPrompt, engine ('auto' | 'native' | 'exa')

    Usage:

    import { createOpenRouter } from "@openrouter/ai-sdk-provider";
    import { generateText } from "ai";
    
    const openrouter = createOpenRouter();
    const result = await generateText({
      model: openrouter("openai/gpt-4o"),
      tools: {
        web_search: openrouter.tools.webSearch({ maxResults: 5 }),
      },
      prompt: "What are the latest news?",
    });

Patch Changes

  • #472 44ba7ec Thanks @robert-j-y! - Fix non-deterministic JSON serialization of tool call arguments that broke prompt caching

    When the AI SDK deserializes and re-serializes tool call arguments across turns, the key insertion order may change. JSON.stringify() follows insertion order, so semantically identical objects could produce different strings, causing cache misses. This adds a recursive key-sorting utility (deterministicStringify) to ensure consistent serialization regardless of key order.

2.5.1

Patch Changes

  • #468 aa7b8c6 Thanks @robert-j-y! - Fix Gemini "Corrupted thought signature" error in multi-turn conversations (issue #418)

    Extend signature validation to also cover google-gemini-v1 format. Previously, only Anthropic-format reasoning entries were validated for signatures. Gemini extended thinking also uses signed thought tokens, and corrupted/missing signatures now get stripped before being sent back to the API.

2.5.0

Minor Changes

  • #463 6ad5a9b Thanks @robert-j-y! - feat: include raw response body in doGenerate and add video URL support

    Issue #432: doGenerate() now includes the raw API response body in response.body, matching the behavior of other AI SDK providers (OpenAI, Anthropic). This gives access to OpenRouter-specific fields like provider, cost_details, is_byok, and native_finish_reason.

    Issue #383: Video files (video/mp4, video/mpeg, video/mov, video/webm) are now correctly converted to video_url content parts instead of being treated as generic files. This fixes "File is not a PDF" errors when sending videos to Gemini and other video-capable models.

2.4.3

Patch Changes

  • #460 7fe7005 Thanks @robert-j-y! - fix: emit tool-input-end events in streaming tool call lifecycle

    Fixes three gaps in the tool call streaming event lifecycle:

    1. Multi-chunk merge path: When tool call arguments arrive across multiple SSE chunks, the tool-input-end event was missing before the tool-call event. Now emits the complete lifecycle: tool-input-start → tool-input-delta(s) → tool-input-end → tool-call.

    2. Flush path: When unsent tool calls are forwarded at stream end, the full tool-input-start → tool-input-delta → tool-input-end sequence was missing. Now checks inputStarted to emit either the full lifecycle (never streamed) or just tool-input-end (partially streamed).

    3. Initial chunk arguments: When the first chunk of a multi-chunk tool call includes partial arguments (e.g. {"q), those arguments were silently dropped instead of being emitted as a tool-input-delta. Now emits the initial arguments as a delta immediately after tool-input-start.

2.4.2

Patch Changes

  • #456 cb7f6c1 Thanks @robert-j-y! - Fix console.warn for signature stripping to respect AI_SDK_LOG_WARNINGS=false, preventing warnings from bleeding through TUI and worker threads. Also generate unique IDs for reasoning and text stream events to avoid downstream ID collisions.

  • #458 cea746a Thanks @robert-j-y! - Fixed duplicate reasoning blocks when signature-only reasoning_details arrive after text content has started. Late-arriving signatures are still accumulated for multi-turn roundtrip via the finish event's providerMetadata, but no longer start a new reasoning block.

2.4.1

Patch Changes

  • #454 b4c3c8f Thanks @robert-j-y! - Stop emitting [REDACTED] as visible reasoning text for encrypted reasoning details. Encrypted reasoning blobs are opaque data used for multi-turn conversation roundtripping and are already preserved in providerMetadata.openrouter.reasoning_details. Previously, the SDK created confusing [REDACTED] reasoning content parts for these details; they are now silently skipped while remaining fully available in provider metadata.

2.4.0

Minor Changes

  • #425 495d4cb Thanks @robert-j-y! - Add appName and appUrl options to createOpenRouter() for setting app identification headers (X-OpenRouter-Title and HTTP-Referer) on every request. This provides a clean, developer-friendly alternative to manually setting headers.

Patch Changes

  • #430 3b31872 Thanks @robert-j-y! - fix: infer tool-calls finishReason when tool calls present but finish_reason is unknown (#420)

    • When finishReason is 'other' (unknown/missing) but tool calls are present, infer 'tool-calls' so agentic loops continue correctly
    • Fixes both streaming (doStream) and non-streaming (doGenerate) paths
  • #416 fece5d0 Thanks @robert-j-y! - Fix mid-stream socket termination (TypeError: terminated) to emit structured error and finish events instead of throwing a raw TypeError

2.3.3

Patch Changes

  • #445 16db454 Thanks @robert-j-y! - fix: strip reasoning.text entries without valid signatures (#423/#439)

    When reasoning_details exist but reasoning.text entries lack a signature (lost during custom pruning, DB serialization, or model switching), Anthropic rejects with "Invalid signature in thinking block". This adds validation to filter out signatureless reasoning.text entries before sending to the API.

2.3.2

Patch Changes

  • #446 b1ccc53 Thanks @robert-j-y! - Fix multimodal tool results being flattened to strings

    When a tool returns output.type = "content" with structured multimodal parts (text + images), those parts were being JSON.stringified instead of preserved as structured content parts. This prevented models from using vision on images in tool results.

    Changes:

    • getToolResultContent() now maps each content part to the appropriate OpenRouter format (text, image_url, file) instead of stringifying
    • ChatCompletionToolMessageParam.content type updated to accept string | Array<ChatCompletionContentPart>

    Fixes #181

2.3.1

Patch Changes

  • #442 a921eb7 Thanks @robert-j-y! - fix: strip reasoning text when reasoning_details are missing to prevent "Invalid signature in thinking block" errors (#423)

2.3.0

Minor Changes

  • #431 f488f97 Thanks @robert-j-y! - feat: add explicit cache_control support for Anthropic automatic prompt caching (#424)

    • Added cache_control field to OpenRouterChatSettings for typed, discoverable configuration
    • Supports both cache_control (snake_case) and cacheControl (camelCase) in providerOptions.openrouter
    • Enables Anthropic automatic caching via top-level request body directive

2.2.5

Patch Changes

  • #428 6e2ff61 Thanks @robert-j-y! - Surface detailed error information from provider metadata in error messages

    When OpenRouter returns an error, the top-level error.message is often generic (e.g. "Provider returned error"). The actual error details from the upstream provider are in error.metadata.raw but were not being surfaced to users.

    Now extractErrorMessage recursively extracts meaningful error messages from metadata.raw (which can be a string, JSON string, or nested object) and includes the provider name when available. For example, instead of just "Provider returned error", users will now see "[Anthropic] Your credit balance is too low".

2.2.4

Patch Changes

  • #427 34b1c27 Thanks @robert-j-y! - fix: preserve thinking block signature in streaming reasoning deltas

    Fixed two bugs causing Anthropic thinking block signatures to be lost during streaming:

    1. Signature-only deltas (containing a signature but no text) were silently dropped by the if (detail.text) guard in the reasoning delta handler. These deltas are now emitted with an empty string text, ensuring the signature propagates to downstream consumers.

    2. Per-delta providerMetadata.reasoning_details only contained the current chunk's details instead of an accumulated snapshot. This meant the signature (which arrives in a later delta) was never visible in earlier deltas' metadata. Now each reasoning delta carries a snapshot of all accumulated reasoning details.

    These fixes prevent "Invalid signature in thinking block" errors in multi-turn conversations with Anthropic models.

2.2.3

Patch Changes

  • #409 7b21d68 Thanks @robert-j-y! - Compute missing token usage detail fields from available API data

    Previously, inputTokens.noCache, outputTokens.text, and inputTokens.cacheWrite were always undefined, even when the data to compute them was available in the API response. This caused downstream dashboards and analytics to receive misleading values.

    Now the provider computes these fields:

    • inputTokens.noCache = total - cacheRead (non-cached input tokens)
    • outputTokens.text = total - reasoning (text output tokens)
    • inputTokens.cacheWrite = passthrough from cache_write_tokens when available

    This applies to all code paths: chat doGenerate, chat doStream, completion doGenerate, and completion doStream.

2.2.2

Patch Changes

  • #405 f7139f1 Thanks @robert-j-y! - Support files parameter in image generation for image editing and image-to-image use cases

2.2.1

Patch Changes

  • #403 e3908c6 Thanks @robert-j-y! - Add support for auto-router plugin to configure allowed models when using openrouter/auto

2.2.0

Minor Changes

  • #399 ad0c2e1 Thanks @robert-j-y! - Fix system message cache control to use block-level format

    When cache control is specified on a system message via providerOptions, the content is now converted to array format with cache_control on the text block, matching the existing behavior for user messages. This ensures consistent Anthropic prompt caching behavior across all message types.

    Before (message-level cache_control):

    {
      "role": "system",
      "content": "...",
      "cache_control": { "type": "ephemeral" }
    }

    After (block-level cache_control):

    {
      "role": "system",
      "content": [
        {
          "type": "text",
          "text": "...",
          "cache_control": { "type": "ephemeral" }
        }
      ]
    }

    Fixes #389

2.1.3

Patch Changes

  • #398 50c932c Thanks @robert-j-y! - Add support for reasoning effort values 'xhigh', 'minimal', and 'none' in the reasoning configuration type. Previously only 'high', 'medium', and 'low' were accepted.

2.1.2

Patch Changes

  • #395 23f02f1 Thanks @robert-j-y! - fix: include accumulated reasoning_details with signature in reasoning-end stream event

    When streaming a text-only response (no tool calls) with reasoning enabled, the reasoning-end event now includes the accumulated reasoning_details (with signature) in providerMetadata. This fixes multi-turn conversation failures with Anthropic models where the signature was lost, causing "Invalid signature in thinking block" errors on subsequent turns.

2.1.1

Patch Changes

  • #365 363e232 Thanks @robert-j-y! - fix: deduplicate reasoning_details across multi-turn conversations to prevent duplicate ID errors

2.1.0

Minor Changes

  • #366 f2b78f5 Thanks @robert-j-y! - Add imageModel() method to OpenRouter provider for image generation support

    This adds the imageModel() method to the OpenRouter provider, enabling image generation through the AI SDK's generateImage() function. The implementation uses OpenRouter's chat completions endpoint with modalities: ['image', 'text'] to generate images.

    Features:

    • Implements ImageModelV3 interface from AI SDK
    • Supports aspectRatio parameter via image_config
    • Supports seed parameter for reproducible generation
    • Supports provider routing settings (order, allow_fallbacks, etc.)
    • Returns appropriate warnings for unsupported features (n > 1, size)
    • Throws UnsupportedFunctionalityError for image editing (files/mask parameters)

    Usage:

    import { createOpenRouter } from "@openrouter/ai-sdk-provider";
    import { generateImage } from "ai";
    
    const openrouter = createOpenRouter();
    const { image } = await generateImage({
      model: openrouter.imageModel("google/gemini-2.5-flash-image"),
      prompt: "A cat wearing a hat",
      aspectRatio: "16:9",
    });
  • #361 da10f19 Thanks @robert-j-y! - Add support for the Response Healing plugin

    The Response Healing plugin automatically validates and repairs malformed JSON responses from AI models. Enable it by adding { id: 'response-healing' } to the plugins array when using structured outputs with generateObject.

    const model = openrouter("openai/gpt-4o", {
      plugins: [{ id: "response-healing" }],
    });
    
    const { object } = await generateObject({
      model,
      schema: z.object({ name: z.string(), age: z.number() }),
      prompt: "Generate a person.",
    });

    Note: Response Healing only works with non-streaming requests.

  • #360 b129d36 Thanks @robert-j-y! - Add includeRawChunks support for streaming

    When includeRawChunks: true is passed to streaming calls, the provider now emits { type: 'raw', rawValue: <parsed chunk> } stream parts for each SSE event, giving consumers access to the raw provider chunks alongside the processed AI SDK stream parts.

    This feature is available for both chat and completion models.

  • #357 f24fac7 Thanks @robert-j-y! - Remove dependency on @openrouter/sdk

    This change removes the external dependency on @openrouter/sdk by inlining the necessary type definitions locally. The types are now defined in src/types/openrouter-api-types.ts.

    This reduces the package's dependency footprint and eliminates potential version conflicts with the SDK.

Patch Changes

  • #359 85d6633 Thanks @robert-j-y! - Fix undefined cost field in providerMetadata causing AI SDK validation failures

  • #362 bd8794a Thanks @robert-j-y! - fix: respect user-specified User-Agent headers without modification

    Previously, when users provided a custom User-Agent header via createOpenRouter({ headers: { 'User-Agent': 'my-app/1.0' } }), the SDK would append its identifier to the header, resulting in my-app/1.0, ai-sdk/openrouter/x.x.x. This was unexpected behavior.

    Now, user-specified User-Agent headers are used verbatim without modification. The SDK identifier is only added as the default when no User-Agent header is provided.

    This also fixes a case-sensitivity bug where User-Agent (capitalized) was not recognized as the same header as user-agent (lowercase), causing duplicate headers to be sent.

    Fixes #300

  • #363 f2d5034 Thanks @robert-j-y! - Populate usage.raw with OpenRouter raw usage accounting object in finish step

  • #364 c6ae94d Thanks @robert-j-y! - Fix missing web search citations by making url_citation schema fields optional

2.0.4

Patch Changes

  • #352 d76d566 Thanks @robert-j-y! - fix: handle tool calls with missing arguments field (#287)

    Made the arguments field optional in the tool_calls schema and default to '{}' (empty JSON object) when missing. This handles cases where upstream providers may omit the arguments field for tools with no parameters.

2.0.3

Patch Changes

  • #351 ac75d1f Thanks @robert-j-y! - fix: only apply message-level cache_control to last text part (#341)

    When message-level cache_control is set on a user message with multiple parts, it now only applies to the last text part. Non-text parts (images, audio, files) no longer inherit message-level cache_control. Part-specific cache_control still takes precedence and works on all part types.

2.0.2

Patch Changes

  • #344 8228294 Thanks @robert-j-y! - Fix parallel tool calls with Claude models when thinking/reasoning is enabled. Previously, reasoning_details were duplicated across all parallel tool calls, causing Anthropic to reject continuation requests.

2.0.1

Patch Changes

2.0.0

Major Changes

  • #307 6fd68db Thanks @pablof7z! - Add AI SDK v6 support with LanguageModelV3 and EmbeddingModelV3 interfaces

Minor Changes

  • #324 d055b96 Thanks @robert-j-y! - Update zod peerDependency from "^3.24.1 || ^v4" to "^3.25.0 || ^4.0.0". This fixes TypeScript errors ("Cannot find module 'zod/v3'") that occur when users have Zod < 3.25.0 installed, as the subpath exports (zod/v3, zod/v4) were only added in Zod 3.25.0.

Patch Changes

  • #326 9f7a125 Thanks @robert-j-y! - Make file content part fields optional and add file_id support. The filename and file_data fields in ChatCompletionContentPartFile are now optional, and a new file_id field has been added for OpenAI file uploads support.

1.5.4

Patch Changes

  • #301 3c0ba4c Thanks @subtleGradient! - Remove TOON encoding/decoding helper functions

    BREAKING CHANGE: Removes @toon-format/toon dependency and related exports (encodeToon, decodeToon, ToonEncodeOptions, ToonDecodeOptions, JsonValue). Users who were using these helpers should import directly from @toon-format/toon instead.

1.5.3

Patch Changes

  • #294 83c6b41 Thanks @subtleGradient! - File annotations from FileParserPlugin are now available in streaming responses. If you use streamText() with PDFs or other files, you can now access parsed file content via providerMetadata.openrouter.annotations in the finish event. This was already available for non-streaming responses.

1.5.2

Patch Changes

  • #288 0caf9f1 Thanks @subtleGradient! - Fix Gemini 3 tool-call conversations stopping prematurely when thoughtSignature (encrypted reasoning) is present. Override finishReason from 'stop' to 'tool-calls' when tool calls and encrypted reasoning are detected.

1.5.1

Patch Changes

1.5.0

Minor Changes

Patch Changes

1.4.1

Patch Changes

  • #279 922dc10 Thanks @subtleGradient! - Add first-class embedding model support via OpenRouterEmbeddingModel -- Thanks @Loule95450 !

  • #281 4294d67 Thanks @subtleGradient! - Add engine option to web_search_options for specifying search engine

    Users can now specify which search engine to use for web search via web_search_options.engine:

    • "native": Use provider's built-in web search
    • "exa": Use Exa's search API
    • undefined: Native if supported, otherwise Exa

    Thanks to @xdagiz for identifying this missing option in #182.

  • #280 f0d3bc9 Thanks @subtleGradient! - Fix responseFormat and tools working together

    Previously, when both responseFormat (with a JSON schema) and tools were provided to doGenerate or doStream, the tools would be silently ignored due to an early return in the getArgs method. Now both options work correctly together.

    Thanks to @soksx for identifying and proposing the fix in #175.

  • #170 261d44a Thanks @louisgv! - Add api_keys parameter for provider-specific API key injection via X-OpenRouter-API-Keys header

1.4.0

Minor Changes

Patch Changes

  • #274 4b7814b Thanks @yogasanas! - Add supportsImageUrls property to indicate image URL support for all models

1.3.0

Minor Changes

  • #263 ed2bec5 Thanks @talos! - Add support for debug flag to echo upstream request body

    • Added debug option to OpenRouterChatSettings with echo_upstream_body boolean
    • The debug flag is passed through to the OpenRouter API in both streaming and non-streaming requests
    • Debug mode only works with streaming requests and returns the upstream request body (with sensitive data redacted) as the first chunk
    • Updated README with usage documentation

Patch Changes

  • #266 c3f6381 Thanks @subtleGradient! - Fix token details in providerMetadata to only be included when present in API response. Previously, promptTokensDetails and completionTokensDetails were always included with default values of 0, which could be misleading. Now they are only included when the API actually returns these details, matching the behavior of costDetails.

  • #268 6ac3814 Thanks @jamespsterling! - Add reasoning_details accumulation and providerMetadata support for multi-turn conversations

    • Accumulate reasoning_details from reasoning parts when converting messages
    • Include reasoning_details in providerMetadata for reasoning delta chunks during streaming
    • Enables users to accumulate reasoning_details across multi-turn conversations
  • #246 78d20ef Thanks @abromberg! - build was failing due to mismatch with @openrouter/sdk types. simply renamed models.Sort to models.ProviderSort and it now builds

  • #260 c38eade Thanks @AviVahl! - adjust sort type to latest @openrouter/sdk

  • #267 89ae694 Thanks @subtleGradient! - Adds support for OpenRouter's BYOK usage accounting. If you have a provider's own API key in your OpenRouter account, cost details are now accessible via usage.costDetails.upstreamInferenceCost -- Thanks @abromberg!

1.2.8

Patch Changes

  • #258 a4ac615 Thanks @louisgv! - Fix reasoning details passing backup to include signature for Text part

1.2.7

Patch Changes

1.2.6

Patch Changes

  • #251 c8c639d Thanks @subtleGradient! - fix: make text field optional in file annotation content schema

    When processing PDFs with the file-parser plugin using Mistral OCR, image elements in the response were failing validation. The schema required a text field on all content elements, but image elements (type: "image_url") only have image_url data—no text. This made it impossible to process PDFs containing images.

    Thanks @smorimoto for the fix! (#235)

1.2.4

Patch Changes

  • #242 55ac920 Thanks @subtleGradient! - reasoning_details preservation for Gemini 3 multi-turn conversations. Thanks @mattapperson!

1.2.3

Patch Changes

  • #232 2b49df4 Thanks @subtleGradient! - Relax zod schemas with passthrough to allow unexpected API fields

    Add .passthrough() to all zod object schemas to prevent validation failures when the API returns extra fields not in our schema definitions. This ensures forward compatibility with API changes and prevents breaking when new fields are added to responses.

1.2.2

Patch Changes

  • #219 8cb1d2d Thanks @subtleGradient! - Replace generic Error instances with proper AI SDK error types for improved error handling consistency and debugging.

    Error Type Changes:

    • Use APICallError for HTTP 200 responses with error payloads (includes url, requestBody, statusCode, headers, and error data)
    • Use NoContentGeneratedError when API returns no choices (with custom context messages)
    • Use InvalidResponseDataError for malformed streaming responses and missing tool calls (with structured data)
    • Use InvalidArgumentError for invalid function arguments (with argument name and serialized value)

    Benefits:

    • Aligns with AI SDK ecosystem error handling patterns
    • Provides structured error data instead of just string messages
    • Enables better error handling and debugging for consumers
    • Preserves all original error context while adding additional debugging information
  • #223 9935792 Thanks @HashimMufti! - fix: support file annotation type for file uploads

1.2.1

Patch Changes

  • #214 f29f61f Thanks @subtleGradient! - Add changeset support for automated release management. This replaces the manual version bump and GitHub Release process with an automated workflow that creates version PRs and publishes to npm when merged.