npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-openrouter-chat-model

v0.1.4

Published

Custom n8n OpenRouter Chat Model sub-node with JSON options support (reasoning, max_tokens, etc.) for use with AI Agents and Chains.

Downloads

216

Readme

OpenRouter Chat Model — custom JSON options

This bundle gives you the PR #21780 feature ("set OpenRouter chat model options as JSON", incl. reasoning / reasoning.effort) applied on top of the current official node ([email protected]), in two forms.

What the PR actually does

It adds a Define Options dropdown to the OpenRouter Chat Model node:

  • Using Fields Below — the original typed fields (temperature, max tokens, …).
  • Using JSON — a free-form JSON box whose keys are sent straight to the OpenRouter chat-completions body (so you can set reasoning, reasoning.effort, provider, etc.).

Because the node runs LangChain's ChatOpenAI under the hood, a few options (max_tokens, reasoning, reasoning.effort, max_retries, timeout) are mapped to LangChain constructor fields explicitly — otherwise LangChain overwrites them with undefined. That mapping is preserved here.

PR vs current master — was it "too far apart"?

No. Diffing the PR file against [email protected], the only real divergences are:

  1. The release added a createOpenRouterFetch wrapper (fixes empty tool-call args from Anthropic-via-OpenRouter). Additive — kept here.
  2. Internal helper imports were moved into @n8n/ai-utilities. The PR still uses the old @utils/* / ../N8nLlmTracing paths.
  3. getProxyAgent gained a timeout-options argument.
  4. The release added a builderHint to the model field.

None of these touch the PR's logic, so it re-applies cleanly. The version in patch/ even keeps the proxy timeout and the tool-args fetch fix, which the original PR had dropped.


Option A — patch/LmChatOpenRouter.node.ts (recommended, most robust)

The official node, on top of [email protected], with the PR feature merged in. It still imports n8n's internal modules, so it is meant to be dropped into a fork / custom build of n8n, not installed as a community package.

packages/@n8n/nodes-langchain/nodes/llms/LmChatOpenRouter/LmChatOpenRouter.node.ts

Then pnpm install && pnpm build (or rebuild just @n8n/n8n-nodes-langchain) and run your custom image. This route shares LangChain instances with the Agent node, so there are no compatibility surprises.

Built against: @langchain/[email protected], @langchain/[email protected] (n8n 2.22.5 catalog). If you target a different n8n version, check that release's catalog.

Option B — n8n-nodes-openrouter-custom/ (standalone community node)

A self-contained community package — install it via Settings → Community Nodes with no custom build. It adds a node called "OpenRouter Chat Model (Custom)" and an "OpenRouter Custom API" credential (same fields as the built-in one: API key + base URL).

To keep it installable, the n8n-internal helpers were removed/replaced:

| Official dependency | In the community node | |---|---| | N8nLlmTracing callback | dropped — no per-call token-usage display in the UI; the model works fully | | makeN8nLlmFailedAttemptHandler | dropped — LangChain's built-in maxRetries still applies | | getProxyAgent | dropped — re-add only if you run behind an HTTP(S) proxy | | getConnectionHintNoticeField | inlined as a static notice | | internal credential type | local OpenRouterCredential interface | | createOpenRouterFetch (tool-args fix) | kept (self-contained) |

Build & install

cd n8n-nodes-openrouter-custom
npm install
npm run build          # tsc + copies the icon into dist/
npm publish            # or: npm pack, then install the tarball

In n8n: Settings → Community Nodes → Installn8n-nodes-openrouter-custom.

⚠️ The one caveat that actually matters: LangChain instance matching

An ai_languageModel sub-node returns a LangChain ChatOpenAI. n8n's AI Agent must recognise it as a LangChain model. If the community package bundles its own copy of @langchain/*, you can hit instanceof/duplicate-module issues and the Agent may reject the model.

That's why @langchain/core and @langchain/openai are declared as peerDependencies (not bundled) — the goal is to use n8n's own copies. Match them to your n8n version (2.22.5 → core 1.1.41, openai 1.4.4). If your n8n install does not expose those modules to community nodes, or the Agent refuses the model, fall back to Option A (the patched node in a custom build), which is guaranteed to share instances.

This LangChain-isolation point — not the PR/master drift — is the real reason a community node "might not just work", and is the honest answer to "what else can we do": run the patched official node in a custom n8n image.

Using JSON mode

Set Define Options → Using JSON and supply e.g.:

{
    "max_retries": 2,
    "timeout": 60000,
    "temperature": 1.0,
    "reasoning": { "effort": "high" },
    "response_format": { "type": "text" }
}

Keys map to the OpenRouter chat-completion request.