Overview
The Grok node for n8n enables you to interact with the Grok API's chat completion endpoint. It allows you to send a message (optionally with a system prompt) to a selected AI model and receive a generated response. This is useful for automating conversations, generating text, or integrating AI-powered chat into your workflows.
Common scenarios:
- Automating customer support responses.
- Generating creative content or summaries.
- Building conversational agents within n8n workflows.
Example:
You can use this node to send a user's question to an AI model and return the answer in an automated workflow, such as replying to emails or chat messages.
Properties
| Display Name | Type | Description |
|---|---|---|
| Model Name or ID | options | Choose from available models or specify an ID using an expression. Required. |
| System Prompt | string | Optional system message to set the assistant's behavior (e.g., "You are a helpful assistant..."). |
| Message | string | The main message to send to the chat model. Required. |
| Temperature | number | Sampling temperature for randomness in output (default: 0.9). |
| Additional Fields | collection | Optional advanced settings: |
| - Frequency Penalty | number | Penalizes new tokens based on frequency (-2.0 to 2.0). |
| - Max Tokens | number | Maximum number of tokens to generate (default: 1000). |
| - Presence Penalty | number | Penalizes new tokens based on their presence so far (-2.0 to 2.0). |
| - Top P | number | Nucleus sampling parameter (default: 1). |
Output
Each input item produces an output with the following structure:
{
"response": "<AI-generated response string>"
}
- If an error occurs and "Continue On Fail" is enabled, the output will be:
{
"error": "<Error message>"
}
Note: The node does not output binary data.
Dependencies
- External Service: Requires access to the Grok API.
- API Key: You must provide a valid Grok API key via n8n credentials (
grokApi). - n8n Configuration: Ensure the credential is set up in your n8n instance.
Troubleshooting
Common Issues:
Missing API Key:
Error:No valid API key provided
Resolution: Set up the Grok API credentials in n8n.Invalid Response Format:
Error:Invalid response format from Grok API
Resolution: The API may have changed its response structure or returned an unexpected result. Check your parameters and the Grok API status.No Models Found:
When loading models, if none are returned, ensure your API key is correct and has access to the Grok service.Other API Errors:
Any other errors from the API will be shown in the error field if "Continue On Fail" is enabled.