- #562
4020201Thanks @robert-j-y! - Addopenrouter.evaluationModel()backed by the OpenRouter Decisions API (/api/alpha/decisions), soexperimental_evaluatefromai@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 underproviderMetadata.openrouter. Model settings acceptuser,provider,session_id,trace, andextraBody; call-levelproviderOptions.openrouteris validated and merged into the request body without being able to overridemodel,state, orquestions. A newdecisionsBaseURLprovider setting configures the Decisions endpoint for proxies whosebaseURLdoes not end in/v1. Theaipeer dependency range is unchanged; onlyevaluationModel()requiresai@7.0.103+.
- #521
b96b207Thanks @christineschen! - Update to latest AI SDK v7 packages and expand test coverage
-
#511
0c90b8bThanks @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@4V4 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 viausage.inputTokenDetails.cacheReadTokens, and reasoning tokens are exposed viausage.outputTokenDetails.reasoningTokens. OpenRouter-specific cost, BYOK, reasoning details, annotations, and cache-control metadata remain available underproviderMetadata.openrouter.
-
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@4V4 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 throughusage.outputTokenDetails.reasoningTokens. OpenRouter-specific cost, BYOK, reasoning details, annotations, and cache-control metadata continue to be exposed throughproviderMetadata.openrouter.
-
#513
384f3c8Thanks @Robinnnnn! - Switch image generation to dedicated/api/v1/imagesendpointMigrates
OpenRouterImageModelfrom the legacy chat completions path (/chat/completionswithmodalities: ["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 filesare mapped toinput_references(array of{ type: "image_url", image_url: { url } }) instead of inline message content partsaspectRatiomaps toaspect_ratio(wasimage_config.aspect_ratio)sizeandnare now passed through (previously emitted warnings)
Response changes:
- Parses
{ created, data: [{ b64_json }], usage }instead of{ choices: [{ message: { images } }] } maxImagesPerCallupdated from 1 to 10 (the new endpoint supports batch generation)
- Sends
- #506
e9cff3aThanks @robert-j-y! - Sendcontent: nullinstead ofcontent: ""for assistant messages that contain only tool calls. Fixes AWS Bedrock Nova rejecting requests with "The text field in the ContentBlock object is blank."
-
#486
82e8014Thanks @robert-j-y! - AddstructuredOutputs.strictsetting to opt out ofresponse_format.json_schema.strict(issue #483).Previously the SDK hardcoded
strict: truewhenever 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 likemoonshotai/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: truefor backward compatibility.
-
#485
bf664b1Thanks @robert-j-y! - FixsupportedUrls['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
bb2d4cbThanks @0age! - fix: stop emitting duplicatetool-callevents when a trailing-whitespace argument delta arrives after a complete tool callIn the streaming chat handler, the merge-into-existing-tool-call path enqueues a
tool-callstream event whenever the accumulatedfunction.argumentsis parsable JSON. BecauseJSON.parseaccepts trailing whitespace, any subsequent argument delta for the same tool-callindex(e.g. a stray space, newline, or closing-token chunk) leaves the arguments parsable and would re-trigger the emit, producing a secondtool-callevent with the sametoolCallId. Downstream tool runners (e.g. Vercel AI SDKstreamText) then execute the tool twice. Observed in production withmoonshotai/kimi-k2.6via OpenRouter, where the user-visible effect was every outbound message being delivered twice.src/chat/index.ts:- Merge-path
tool-callemit is now gated on!toolCall.sent, mirroring the new-path behavior. Thesentflag 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
indexand asserts exactly onetool-callevent is emitted.
- Merge-path
-
#487
4588197Thanks @louisgv! - fix: preserve empty reasoning_details arrays in multi-turn conversationsSome 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 bylength > 0). - Both
reasoning-endemit sites now always includeproviderMetadata.openrouter.reasoning_details, removing thelength > 0ternary that would drop the field entirely.
src/chat/convert-to-openrouter-chat-messages.ts:candidateReasoningDetailsselection now usesArray.isArray(messageReasoningDetails)instead ofmessageReasoningDetails.length > 0— an explicit[]is now treated as "metadata was provided" rather than "metadata was absent", and no longer falls through tofindFirstReasoningDetails.- The top-level
if (candidateReasoningDetails)guard no longer requireslength > 0; an empty candidate array still triggers the dedup/signature-filter block. finalReasoningDetailsis now always set touniqueDetails(the deduplicated array), never collapsed toundefined. When all entries were duplicate or signature-stripped, the empty array is preserved as a meaningful signal.effectiveReasoningstill requiresfinalReasoningDetails.length > 0— reasoning text is never sent alongside an empty details array.
- Stream finish event now always sets
- #479
e381895Thanks @abhinav-pola! - Add video generation support viaprovider.videoModel()implementing theExperimental_VideoModelV3interface. Supports text-to-video and image-to-video generation with configurable aspect ratio, resolution, duration, seed, audio generation, and provider options passthrough.
-
#465
d32823eThanks @robert-j-y! - feat: support Anthropic eager_input_streaming parameter via tool providerOptionsTools can now pass
eager_input_streaming: truethroughproviderOptions.openrouter.eager_input_streamingto enable Anthropic's fine-grained tool streaming, reducing latency for large tool outputs.
-
#477
918d564Thanks @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
839f9b0Thanks @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
916c4c1Thanks @robert-j-y! - feat: add temperature and other common settings to model-level configuration
-
#475
5b8fa40Thanks @robert-j-y! - Addopenrouter.tools.webSearch()provider-defined tool for server-side web search- New
src/tool/web-search.ts— web search tool factory usingcreateProviderToolFactory - Updated
OpenRouterProviderinterface withtools.webSearchproperty - Updated
getArgs()to mapLanguageModelV3ProviderToolto 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?", });
- New
-
#472
44ba7ecThanks @robert-j-y! - Fix non-deterministic JSON serialization of tool call arguments that broke prompt cachingWhen 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.
-
#468
aa7b8c6Thanks @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.
-
#463
6ad5a9bThanks @robert-j-y! - feat: include raw response body in doGenerate and add video URL supportIssue #432:
doGenerate()now includes the raw API response body inresponse.body, matching the behavior of other AI SDK providers (OpenAI, Anthropic). This gives access to OpenRouter-specific fields likeprovider,cost_details,is_byok, andnative_finish_reason.Issue #383: Video files (
video/mp4,video/mpeg,video/mov,video/webm) are now correctly converted tovideo_urlcontent 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.
-
#460
7fe7005Thanks @robert-j-y! - fix: emit tool-input-end events in streaming tool call lifecycleFixes three gaps in the tool call streaming event lifecycle:
-
Multi-chunk merge path: When tool call arguments arrive across multiple SSE chunks, the
tool-input-endevent was missing before thetool-callevent. Now emits the complete lifecycle:tool-input-start → tool-input-delta(s) → tool-input-end → tool-call. -
Flush path: When unsent tool calls are forwarded at stream end, the full
tool-input-start → tool-input-delta → tool-input-endsequence was missing. Now checksinputStartedto emit either the full lifecycle (never streamed) or justtool-input-end(partially streamed). -
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 atool-input-delta. Now emits the initial arguments as a delta immediately aftertool-input-start.
-
-
#456
cb7f6c1Thanks @robert-j-y! - Fix console.warn for signature stripping to respectAI_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
cea746aThanks @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.
- #454
b4c3c8fThanks @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 inproviderMetadata.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.
- #425
495d4cbThanks @robert-j-y! - AddappNameandappUrloptions tocreateOpenRouter()for setting app identification headers (X-OpenRouter-TitleandHTTP-Referer) on every request. This provides a clean, developer-friendly alternative to manually setting headers.
-
#430
3b31872Thanks @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
fece5d0Thanks @robert-j-y! - Fix mid-stream socket termination (TypeError: terminated) to emit structured error and finish events instead of throwing a raw TypeError
-
#445
16db454Thanks @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.
-
#446
b1ccc53Thanks @robert-j-y! - Fix multimodal tool results being flattened to stringsWhen 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 stringifyingChatCompletionToolMessageParam.contenttype updated to acceptstring | Array<ChatCompletionContentPart>
Fixes #181
- #442
a921eb7Thanks @robert-j-y! - fix: strip reasoning text when reasoning_details are missing to prevent "Invalid signature in thinking block" errors (#423)
-
#431
f488f97Thanks @robert-j-y! - feat: add explicit cache_control support for Anthropic automatic prompt caching (#424)- Added
cache_controlfield toOpenRouterChatSettingsfor typed, discoverable configuration - Supports both
cache_control(snake_case) andcacheControl(camelCase) inproviderOptions.openrouter - Enables Anthropic automatic caching via top-level request body directive
- Added
-
#428
6e2ff61Thanks @robert-j-y! - Surface detailed error information from provider metadata in error messagesWhen OpenRouter returns an error, the top-level
error.messageis often generic (e.g. "Provider returned error"). The actual error details from the upstream provider are inerror.metadata.rawbut were not being surfaced to users.Now
extractErrorMessagerecursively extracts meaningful error messages frommetadata.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".
-
#427
34b1c27Thanks @robert-j-y! - fix: preserve thinking block signature in streaming reasoning deltasFixed two bugs causing Anthropic thinking block signatures to be lost during streaming:
-
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. -
Per-delta
providerMetadata.reasoning_detailsonly 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.
-
-
#409
7b21d68Thanks @robert-j-y! - Compute missing token usage detail fields from available API dataPreviously,
inputTokens.noCache,outputTokens.text, andinputTokens.cacheWritewere alwaysundefined, 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 fromcache_write_tokenswhen available
This applies to all code paths: chat
doGenerate, chatdoStream, completiondoGenerate, and completiondoStream.
- #405
f7139f1Thanks @robert-j-y! - Supportfilesparameter in image generation for image editing and image-to-image use cases
- #403
e3908c6Thanks @robert-j-y! - Add support forauto-routerplugin to configure allowed models when usingopenrouter/auto
-
#399
ad0c2e1Thanks @robert-j-y! - Fix system message cache control to use block-level formatWhen cache control is specified on a system message via
providerOptions, the content is now converted to array format withcache_controlon 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
- #398
50c932cThanks @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.
-
#395
23f02f1Thanks @robert-j-y! - fix: include accumulated reasoning_details with signature in reasoning-end stream eventWhen 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.
- #365
363e232Thanks @robert-j-y! - fix: deduplicate reasoning_details across multi-turn conversations to prevent duplicate ID errors
-
#366
f2b78f5Thanks @robert-j-y! - Add imageModel() method to OpenRouter provider for image generation supportThis adds the
imageModel()method to the OpenRouter provider, enabling image generation through the AI SDK'sgenerateImage()function. The implementation uses OpenRouter's chat completions endpoint withmodalities: ['image', 'text']to generate images.Features:
- Implements
ImageModelV3interface from AI SDK - Supports
aspectRatioparameter viaimage_config - Supports
seedparameter for reproducible generation - Supports provider routing settings (order, allow_fallbacks, etc.)
- Returns appropriate warnings for unsupported features (n > 1, size)
- Throws
UnsupportedFunctionalityErrorfor 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", });
- Implements
-
#361
da10f19Thanks @robert-j-y! - Add support for the Response Healing pluginThe 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 withgenerateObject.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
b129d36Thanks @robert-j-y! - Add includeRawChunks support for streamingWhen
includeRawChunks: trueis 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
f24fac7Thanks @robert-j-y! - Remove dependency on @openrouter/sdkThis change removes the external dependency on
@openrouter/sdkby inlining the necessary type definitions locally. The types are now defined insrc/types/openrouter-api-types.ts.This reduces the package's dependency footprint and eliminates potential version conflicts with the SDK.
-
#359
85d6633Thanks @robert-j-y! - Fix undefined cost field in providerMetadata causing AI SDK validation failures -
#362
bd8794aThanks @robert-j-y! - fix: respect user-specified User-Agent headers without modificationPreviously, when users provided a custom
User-Agentheader viacreateOpenRouter({ headers: { 'User-Agent': 'my-app/1.0' } }), the SDK would append its identifier to the header, resulting inmy-app/1.0, ai-sdk/openrouter/x.x.x. This was unexpected behavior.Now, user-specified
User-Agentheaders are used verbatim without modification. The SDK identifier is only added as the default when noUser-Agentheader is provided.This also fixes a case-sensitivity bug where
User-Agent(capitalized) was not recognized as the same header asuser-agent(lowercase), causing duplicate headers to be sent.Fixes #300
-
#363
f2d5034Thanks @robert-j-y! - Populate usage.raw with OpenRouter raw usage accounting object in finish step -
#364
c6ae94dThanks @robert-j-y! - Fix missing web search citations by making url_citation schema fields optional
-
#352
d76d566Thanks @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.
-
#351
ac75d1fThanks @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.
- #344
8228294Thanks @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.
- #337
09f85dcThanks @robert-j-y! - Fix ai peer dependency from exact version 6.0.3 to ^6.0.0
- #307
6fd68dbThanks @pablof7z! - Add AI SDK v6 support with LanguageModelV3 and EmbeddingModelV3 interfaces
- #324
d055b96Thanks @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.
- #326
9f7a125Thanks @robert-j-y! - Make file content part fields optional and add file_id support. Thefilenameandfile_datafields inChatCompletionContentPartFileare now optional, and a newfile_idfield has been added for OpenAI file uploads support.
-
#301
3c0ba4cThanks @subtleGradient! - Remove TOON encoding/decoding helper functionsBREAKING 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.
- #294
83c6b41Thanks @subtleGradient! - File annotations from FileParserPlugin are now available in streaming responses. If you usestreamText()with PDFs or other files, you can now access parsed file content viaproviderMetadata.openrouter.annotationsin the finish event. This was already available for non-streaming responses.
- #288
0caf9f1Thanks @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.
- #295
2fbe4e5Thanks @subtleGradient! - Patch transitive security vulnerabilities in glob and js-yaml dev dependencies
- #276
eb7d3a2Thanks @jamespsterling! - Add TOON encoding/decoding helper functions for token-efficient data serialization
-
#279
922dc10Thanks @subtleGradient! - Add first-class embedding model support via OpenRouterEmbeddingModel -- Thanks @Loule95450 ! -
#281
4294d67Thanks @subtleGradient! - Addengineoption toweb_search_optionsfor specifying search engineUsers 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 APIundefined: Native if supported, otherwise Exa
Thanks to @xdagiz for identifying this missing option in #182.
-
#280
f0d3bc9Thanks @subtleGradient! - Fix responseFormat and tools working togetherPreviously, when both
responseFormat(with a JSON schema) andtoolswere provided todoGenerateordoStream, the tools would be silently ignored due to an early return in thegetArgsmethod. Now both options work correctly together.Thanks to @soksx for identifying and proposing the fix in #175.
-
#170
261d44aThanks @louisgv! - Add api_keys parameter for provider-specific API key injection via X-OpenRouter-API-Keys header
-
#272
4c7176eThanks @subtleGradient! - Add support for FileParser annotations to enable "Skip Parsing Costs" feature- Annotations from file parsing are now exposed via
providerMetadata.openrouter.annotations - Pass annotations back via
providerOptions.openrouter.annotationsto skip re-parsing costs - See https://openrouter.ai/docs/guides/overview/multimodal/pdfs#skip-parsing-costs
- Annotations from file parsing are now exposed via
- #274
4b7814bThanks @yogasanas! - Add supportsImageUrls property to indicate image URL support for all models
-
#263
ed2bec5Thanks @talos! - Add support for debug flag to echo upstream request body- Added
debugoption toOpenRouterChatSettingswithecho_upstream_bodyboolean - 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
- Added
-
#266
c3f6381Thanks @subtleGradient! - Fix token details in providerMetadata to only be included when present in API response. Previously,promptTokensDetailsandcompletionTokensDetailswere 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 ofcostDetails. -
#268
6ac3814Thanks @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
78d20efThanks @abromberg! - build was failing due to mismatch with @openrouter/sdk types. simply renamed models.Sort to models.ProviderSort and it now builds -
#260
c38eadeThanks @AviVahl! - adjust sort type to latest @openrouter/sdk -
#267
89ae694Thanks @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!
- #258
a4ac615Thanks @louisgv! - Fix reasoning details passing backup to include signature for Text part
- #255
f48fa96Thanks @subtleGradient! - support for audio input with input_audio format (#241) Thanks @Karavil!
-
#251
c8c639dThanks @subtleGradient! - fix: make text field optional in file annotation content schemaWhen processing PDFs with the file-parser plugin using Mistral OCR, image elements in the response were failing validation. The schema required a
textfield on all content elements, but image elements (type: "image_url") only haveimage_urldata—no text. This made it impossible to process PDFs containing images.Thanks @smorimoto for the fix! (#235)
- #242
55ac920Thanks @subtleGradient! - reasoning_details preservation for Gemini 3 multi-turn conversations. Thanks @mattapperson!
-
#232
2b49df4Thanks @subtleGradient! - Relax zod schemas with passthrough to allow unexpected API fieldsAdd
.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.
-
#219
8cb1d2dThanks @subtleGradient! - Replace genericErrorinstances with proper AI SDK error types for improved error handling consistency and debugging.Error Type Changes:
- Use
APICallErrorfor HTTP 200 responses with error payloads (includes url, requestBody, statusCode, headers, and error data) - Use
NoContentGeneratedErrorwhen API returns no choices (with custom context messages) - Use
InvalidResponseDataErrorfor malformed streaming responses and missing tool calls (with structured data) - Use
InvalidArgumentErrorfor 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
- Use
-
#223
9935792Thanks @HashimMufti! - fix: support file annotation type for file uploads
- #214
f29f61fThanks @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.