Reference · Tools

Grok Chat

Chat with xAI Grok models using the OpenAI-compatible API.

Action AI v1

Grok Chat sends a user message and optional system prompt to an xAI Grok model and returns the assistant's reply, with temperature, max tokens, top-p and frequency and presence penalties all exposed. Use it wherever you want generation routed specifically to Grok — drafting replies, summarising, or any step where you have decided Grok is the right model.

Node type
Action
Parameters
6
Outputs
Output, Error
Credentials
xAI

Grok Chat

Chat with xAI Grok models using the OpenAI-compatible API.

Overview

Grok Chat sends a user message (with an optional system prompt) to the xAI Grok API and returns the model’s response. Supports model selection, temperature, max tokens, top-p, frequency penalty, and presence penalty. Returns the assistant’s message text, model name, token usage, and finish reason.

Category: AI
Tool Name: grok_chat
Version: 1

Appearance: Icon: brain | Color: #000000

Node Type

Action — processes input items and produces output

Input / Output

DirectionPort(s)
InputInput
OutputOutput, Error

Credentials

This tool requires xAI credentials. See the Credentials Guide for setup instructions.

Parameters

ParameterTypeRequiredDefaultDescription
ModeloptionsNoPlatform defaultThe Grok model to use for chat completion.
Options: the Grok chat models currently available — the dropdown tracks the model catalog, so it changes as xAI’s line-up changes.
System PromptstringNoOptional system prompt to set the behavior and context for the model. Supports expressions like {{ $json.persona }}.
User MessagestringYesThe user message to send to Grok. If empty, falls back to the input item’s “message” or “prompt” field. Supports expressions.
OptionscollectionNo{}Optional generation settings — add only the fields you want to override.
— TemperaturenumberNo1Controls randomness. Lower values make output more focused; higher values more creative. Range: 0-2.
— Max TokensnumberNo4096Maximum number of tokens to generate in the response.
— Top PnumberNo1Nucleus sampling: only tokens with top-p cumulative probability are considered. Range: 0-1.
— Frequency PenaltynumberNo0Penalizes tokens based on their frequency in the text so far. Range: -2 to 2.
— Presence PenaltynumberNo0Penalizes tokens based on whether they appear in the text so far. Range: -2 to 2.
— Response Field NamestringNoresponseThe output field name where the AI response text will be stored.
Include InputbooleanNofalseWhether to include the original input item fields in the output alongside the AI response.
Max ConcurrencynumberNo10Maximum number of items to process concurrently.

Output Data

One output item per input item. The reply text is written to the field named by Response Field Name (response by default). The rest of the input JSON is carried over only when Include Input is on; binary data from the input item is always forwarded.

  • response — the assistant’s reply text, under whatever name Response Field Name is set to.
  • model — the model that produced the reply.
  • usage — the token counts reported by xAI for the request.
  • finishReason — why generation stopped, as reported by xAI.

Reference the result downstream by expression, e.g. {{ $json.response }}.

Usage Examples

  • Ask Grok a question and get a text response
  • Generate content using Grok with a system prompt
  • Process a batch of prompts through Grok
  • Use a faster Grok model for quick completions with low latency
  • Chat with Grok using custom temperature and max tokens

Example Configuration

Ask a single question with the defaults:

{
  "type": "grok_chat",
  "parameters": {
    "userMessage": "What is the capital of France?"
  }
}

Answer with a system prompt and tighter generation settings:

{
  "type": "grok_chat",
  "parameters": {
    "systemPrompt": "You are a careful analyst. Answer in one paragraph.",
    "userMessage": "Summarise the risks in this report: {{ $json.body }}",
    "options": {
      "temperature": 0.3,
      "maxTokens": 2048,
      "responseFieldName": "analysis"
    }
  }
}

Classify a batch of items, reading each prompt from the item itself:

{
  "type": "grok_chat",
  "parameters": {
    "systemPrompt": "Classify the sentiment as exactly one of: positive, negative, neutral.",
    "userMessage": "",
    "includeInput": true,
    "maxConcurrency": 20,
    "options": {
      "temperature": 0,
      "maxTokens": 16,
      "responseFieldName": "sentiment"
    }
  }
}

Error Handling

ModeBehavior
stopHalts workflow on first error
continueSkips failed items, passes successful ones through
errorPortRoutes failed items to Error output port

Tips

Grok Chat sends a user message and optional system prompt to xAI Grok models via an OpenAI-compatible chat completions API, with controls for temperature, max tokens, top-p, and frequency and presence penalties. Use it when your workflow requires generation or reasoning tasks routed specifically to xAI Grok models. It outputs the assistant response text, model name, token usage counts, and finish reason on the main channel, or routes failures to the error output.

Frequently asked questions

What does the node return?

The assistant response text, the model name, prompt and completion token counts, and the finish reason. Token counts are useful for tracking spend across a batch.

Which sampling controls are available?

Temperature, max tokens, top-p, and frequency and presence penalties. That is the standard chat-completions set, so behaviour matches what you would expect from the OpenAI-compatible interface.

Why does the finish reason matter?

It tells you whether the model stopped naturally or hit the max-tokens ceiling. A truncated answer usually looks like a sensible response that stops mid-thought — the finish reason is how you detect it programmatically.

How do I handle failures without stopping the run?

Set the node's error handling to continue using the error output. Failed items route to the Error port while the rest of the batch proceeds.

Build with the Grok Chat node

Drop it into a workflow, wire it to an agent, or call it on a schedule. You'll need xAI credentials first.

Open BusyBot

Last updated . Spotted something wrong? Tell us.