n8n-nodes-grok
v0.0.20
Published
n8n node for Grok API integration
Downloads
1,475
Maintainers
Readme
n8n-nodes-grok
This is an n8n community node for Grok API integration. It allows you to interact with various AI models through the Grok platform directly from your n8n workflows.
n8n is a fair-code licensed workflow automation platform.
Grok 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:
- Open your n8n instance
- Go to "Settings" > "Community Nodes"
- Select "Install"
- Enter
n8n-nodes-grok
in the "Enter npm package name" field - Agree to the risks of using community nodes (if prompted)
- Click "Install"
After installation, the node will be available in the "Grok" category in the node palette.
Manual Installation (Advanced)
If you prefer manual installation or are using a custom n8n setup:
- Open your n8n installation directory
- Navigate to the
nodes
subdirectory - Run the following command:
npm install n8n-nodes-grok
- 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:
- Clear your browser cache
- Restart your n8n instance
- If using Docker, rebuild and restart your container:
docker-compose down docker-compose build docker-compose up -d
- For server deployments, restart the n8n service:
sudo systemctl restart n8n
Usage
- Add the Grok node to your workflow
- Configure the Grok API credentials (see Configuration section)
- Select the desired operation (currently only 'Chat' is available)
- Choose an AI model from the dropdown list
- (Optional) Provide a system prompt to set the behavior of the AI
- Enter your message
- Adjust additional parameters as needed (temperature, max tokens, etc.)
- 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
Grok API Credentials
To use this node, you need to set up Grok API credentials:
- Sign up for an account at Grok
- Generate an API key in your Grok dashboard
- In n8n, create a new credential of type 'Grok API'
- 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
- Add a "Manual" trigger node
- Connect an Grok node
- Configure the Grok node:
- Operation: Chat
- Model: Choose a model (e.g., "gpt-3.5-turbo")
- Message: "Hello, can you explain what n8n is?"
- Execute the workflow
- The Grok node will return the AI's response explaining n8n
Dynamic System Prompt
- Start with a "Manual" trigger node
- Add a "Set" node to define a variable for the system prompt
- Connect an Grok node
- Configure the Grok node:
- Operation: Chat
- Model: Choose a model
- System Prompt: {{$node["Set"].json["systemPrompt"]}}
- Message: "What's your primary function?"
- Execute the workflow
- 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:
- Fork the repository
- Create a new branch for your feature
- Commit your changes
- Push to the branch
- 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 Grok
Grok 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. Grok 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.