Reference · Tools

Grok Batch

Process multiple Grok requests as a batch job.

Action AI v1

Grok Batch processes a large set of Grok prompts as a single asynchronous job rather than one call at a time, assembling a JSONL file, uploading it and submitting it to xAI. It returns batch status and, once finished, the completed chat completions. Use it for volume work where nobody is waiting — classifying a backlog of tickets overnight.

Node type
Action
Parameters
7
Outputs
Output, Error
Credentials
xAI

Grok Batch

Process multiple Grok requests as a batch job.

Overview

Grok Batch uses the xAI Batch API to process many chat completion requests asynchronously. Three operations are supported: create (collect the incoming items into one batch job and submit it), check (look up a batch’s status), and cancel (stop a running batch). On create, every input item is folded into a single batch request. The node can optionally poll for completion with a configurable interval and timeout.

Category: AI
Tool Name: grok_batch
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.

Operations

OperationValueDescription
Create BatchcreateCreate a new batch job from input items.
Check StatuscheckCheck the status of an existing batch.
Cancel BatchcancelCancel a running batch.

Parameters

Create Batch (create)

ParameterTypeRequiredDefaultDescription
ModeloptionsNoPlatform defaultThe Grok model to use for batch requests.
Options: the Grok chat models currently available — the dropdown tracks the model catalog, so it changes as xAI’s line-up changes.
System PromptstringNoSystem instructions applied to all batch requests. Only applies to create operation. Supports expressions.

There is no prompt parameter on this operation. The user message for each batch request is read from the input item’s message, prompt or text field, in that order; items with none of those fields are skipped.

Check Status (check)

ParameterTypeRequiredDefaultDescription
Batch IDstringNoThe batch ID to check or cancel. Falls back to item.json.batchId if empty. Supports expressions.

Cancel Batch (cancel)

ParameterTypeRequiredDefaultDescription
Batch IDstringNoThe batch ID to check or cancel. Falls back to item.json.batchId if empty. Supports expressions.

All Operations

ParameterTypeRequiredDefaultDescription
OptionscollectionNo{}Optional batch, polling and output settings — add only the fields you want to override.
— Completion WindowstringNo24hTime window for batch completion.
— Poll Interval (ms)numberNo30000How often to poll for completion status in milliseconds.
— Max Poll Duration (ms)numberNo600000Maximum total time to spend polling for completion in milliseconds.
— Wait for CompletionbooleanNofalseIf true, poll until the batch completes (or fails/expires) before returning. Applies to the create operation.
— Response Field NamestringNobatchField name in the output JSON where the batch result will be placed.
Include InputbooleanNofalseWhether to include the original input item fields in the output.
Max ConcurrencynumberNo5Maximum number of items to process concurrently (for check/cancel operations).

Output Data

One output item per input item in every operation — create submits one batch for the whole run but still echoes the result back onto each item. The rest of the input JSON is carried over only when Include Input is on; binary data from the input item is forwarded.

The batch record is written to the field named by Response Field Name (batch by default), alongside these flat fields:

OperationFields on the output item
createbatch (the batch record, polled to its terminal state when Wait for Completion is on), batchId, status, inputFileId, requestCount (how many requests went into the batch), and outputFileId once xAI has produced results
check / cancelbatch (the batch record), batchId, status, plus outputFileId and requestCounts when xAI returns them

If no input item carries a usable prompt, create emits one item per input with batch: null, batchId: null and status: "empty" rather than submitting anything.

Reference the result downstream by expression, e.g. {{ $json.batchId }} or {{ $json.status }}.

Usage Examples

  • Submit 1000 prompts as a single Grok batch job
  • Check the status of a running Grok batch
  • Cancel a pending Grok batch
  • Create a batch of Grok chat completions
  • Submit batch with polling to wait for completion

Example Configuration

Submit the incoming items as one batch and return immediately:

{
  "type": "grok_batch",
  "parameters": {
    "operation": "create",
    "systemPrompt": "Extract the key entities from the provided text and return them as a JSON array.",
    "includeInput": true,
    "options": {
      "completionWindow": "24h",
      "waitForCompletion": false
    }
  }
}

Submit and block until the batch finishes:

{
  "type": "grok_batch",
  "parameters": {
    "operation": "create",
    "systemPrompt": "Translate the following text to Spanish.",
    "options": {
      "completionWindow": "2h",
      "waitForCompletion": true,
      "pollIntervalMs": 20000,
      "maxPollDurationMs": 360000,
      "responseFieldName": "translationBatch"
    }
  }
}

Check a batch created by an earlier node:

{
  "type": "grok_batch",
  "parameters": {
    "operation": "check",
    "batchId": "{{ $json.batchId }}",
    "maxConcurrency": 5
  }
}

Cancel a batch that is no longer needed:

{
  "type": "grok_batch",
  "parameters": {
    "operation": "cancel",
    "batchId": "{{ $json.batchId }}"
  }
}

Error Handling

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

Tips

Grok Batch processes multiple xAI chat completion requests together by building a JSONL file, uploading it, and submitting it as a single asynchronous batch job. Use it when handling large volumes of Grok prompts where real-time responses are not required, reducing overhead compared to individual API calls. It outputs batch status information and completed chat completion results on the main channel, with failures routed to the error channel.

Frequently asked questions

When is batching worth it over the normal Grok Chat node?

When you have many prompts and no one is waiting on the answer. Batching cuts the per-request overhead of individual API calls, but results arrive asynchronously — so it is wrong for anything interactive.

How are the requests submitted?

The node builds a JSONL file from your requests, uploads it, and submits it as one batch job. You do not construct or manage the file yourself.

What comes back on the output?

Batch status information and the completed chat completion results. Failures route to the Error output so a problem with the job does not silently stall the workflow.

Which credential does it need?

An xAI credential, the same one the other Grok nodes use, so a single credential covers chat, reasoning and batch work.

Build with the Grok Batch 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.