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 🙏

© 2024 – Pkg Stats / Ryan Hefner

n8n-nodes-openrouter

v0.3.37

Published

n8n node for OpenRouter API integration

Downloads

2,964

Readme

n8n-nodes-openrouter

This is an n8n community node for OpenRouter API integration. It allows you to interact with various AI models through the OpenRouter platform directly from your n8n workflows.

Follow on X

n8n is a fair-code licensed workflow automation platform.

OpenRouter is a platform that provides access to various AI models through a unified API.

Features

  • Interact with multiple AI models through a single node
  • Send chat messages to AI models
  • Customize model parameters such as temperature, max tokens, frequency penalty, and presence penalty
  • View truncated model descriptions and pricing information in the model selector
  • Easy integration with n8n workflows

Installation

Community Node (Recommended)

To install this node as a community node in n8n, follow these steps:

  1. Open your n8n instance
  2. Go to "Settings" > "Community Nodes"
  3. Select "Install"
  4. Enter n8n-nodes-openrouter in the "Enter npm package name" field
  5. Agree to the risks of using community nodes (if prompted)
  6. Click "Install"

After installation, the node will be available in the "OpenRouter" category in the node palette.

Manual Installation (Advanced)

If you prefer manual installation or are using a custom n8n setup:

  1. Open your n8n installation directory
  2. Navigate to the nodes subdirectory
  3. Run the following command:
    npm install n8n-nodes-openrouter
  4. Restart your n8n instance

Note: If you're using Docker or a server deployment, you may need to rebuild your container or restart your server for the changes to take effect.

Troubleshooting

If you encounter issues with the node not updating to new versions correctly or not displaying changes inside n8n, try the following:

  1. Clear your browser cache
  2. Restart your n8n instance
  3. If using Docker, rebuild and restart your container:
    docker-compose down
    docker-compose build
    docker-compose up -d
  4. For server deployments, restart the n8n service:
    sudo systemctl restart n8n

Usage

  1. Add the OpenRouter node to your workflow
  2. Configure the OpenRouter API credentials (see Configuration section)
  3. Select the desired operation (currently only 'Chat' is available)
  4. Choose an AI model from the dropdown list
  5. (Optional) Provide a system prompt to set the behavior of the AI
  6. Enter your message
  7. Adjust additional parameters as needed (temperature, max tokens, etc.)
  8. Execute the node to receive the AI's response

Model Selection

The model selector provides truncated descriptions of each available model along with pricing information. The pricing is displayed as cost per 1 million tokens for both prompt and completion. This allows you to make informed decisions about which model to use based on capabilities and cost.

Configuration

OpenRouter API Credentials

To use this node, you need to set up OpenRouter API credentials:

  1. Sign up for an account at OpenRouter
  2. Generate an API key in your OpenRouter dashboard
  3. In n8n, create a new credential of type 'OpenRouter API'
  4. Enter your API key

Node Parameters

  • Operation: Currently, only 'Chat' is available
  • Model: Select the AI model you want to use
  • System Prompt: (Optional) Set the behavior or role of the AI assistant
  • Message: The user's input message to the AI
  • Temperature: Controls the randomness of the AI's output (0.0 to 1.0)
  • Additional Fields:
    • Frequency Penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far.
    • Max Tokens: The maximum number of tokens to generate in the chat completion.
    • Presence Penalty: Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far.
    • Top P: An alternative to sampling with temperature, called nucleus sampling. Top_p of 0.1 means only the tokens comprising the top 10% probability mass are considered.

Examples

Basic Chat Workflow

  1. Add a "Manual" trigger node
  2. Connect an OpenRouter node
  3. Configure the OpenRouter node:
    • Operation: Chat
    • Model: Choose a model (e.g., "gpt-3.5-turbo")
    • Message: "Hello, can you explain what n8n is?"
  4. Execute the workflow
  5. The OpenRouter node will return the AI's response explaining n8n

Dynamic System Prompt

  1. Start with a "Manual" trigger node
  2. Add a "Set" node to define a variable for the system prompt
  3. Connect an OpenRouter node
  4. Configure the OpenRouter node:
    • Operation: Chat
    • Model: Choose a model
    • System Prompt: {{$node["Set"].json["systemPrompt"]}}
    • Message: "What's your primary function?"
  5. Execute the workflow
  6. The AI will respond based on the system prompt set in the "Set" node

Support

If you encounter any issues or have questions about this node, please open an issue on the GitHub repository.

Contributing

Contributions to improve this node are welcome. Please follow these steps:

  1. Fork the repository
  2. Create a new branch for your feature
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

License

This project is licensed under the MIT License.

About n8n

n8n is a free and open fair-code licensed workflow automation tool. It can be self-hosted, easily extended, and used to automate workflows across various services and applications. n8n enables you to connect anything to everything.

About OpenRouter

OpenRouter is a platform that provides a unified API to access various AI models. It allows developers to integrate multiple AI services into their applications without managing separate API integrations for each model provider. OpenRouter supports a wide range of models from different providers, making it easier to experiment with and deploy various AI capabilities in your workflows.

Changelog

0.3.36

  • Added truncated model descriptions in the model selector
  • Included pricing information (cost per 1M tokens) for each model
  • Updated default temperature to 0.9
  • Various bug fixes and performance improvements

For a full list of changes, please refer to the CHANGELOG.md file.