Skip to main content

xAI Grok Component

xAI Grok is an AI-powered component that provides advanced chat and image generation capabilities.

Component key: xai-grok

Description

xAI Grok is an advanced AI model developed by xAI, offering powerful chat completions and image generation capabilities.

Use the component to generate AI-powered text responses and create images from text prompts.

Connections

xAI Grok Connection

Navigate to XAI Grok API and generate an API key. Enter the key value into the connection configuration of the integration.

InputNotesExample
API Key
string
/ Required
token
Your xAI Grok API key.
xai-XqaU...

Data Sources

Select Model

Select a model from the list of models | key: selectModel | type: picklist

InputNotes
Connection
connection
/ Required
connection
 

{
"result": [
{
"label": "grok-3-beta",
"key": "grok-3-beta"
}
]
}

Actions

Create Chat Completion

Create a chat completion using xAI Grok | key: createChatCompletion

InputDefaultNotesExample
Additional Fields
code
additionalFields
Additional fields that are not supported by the action inputs. See [xAI API docs](https://docs.x.ai/docs/api-reference#chat-completions) for possible values.
Connection
connection
/ Required
connection
 
 
 
Messages
code
/ Required
messages
A list of messages that make up the the chat conversation. Different models support different message types, such as image and text.
Model
string
/ Required
model
Model name for the model to use. Obtainable [here](https://docs.x.ai/docs/models).
grok-2-latest
Stream
boolean
stream
false
If set, partial message deltas will be sent.
 
Temperature
string
temperature
1
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
1
Top P
string
topP
1
An alternative to sampling with `Temperature`, called nucleus sampling, where the model considers the results of the tokens with `Top P` probability mass. It is generally recommended to alter this or `Temperature` but not both.
1

{
"data": {
"id": "a733959b-03c4-4944-b53a-af900075ba57",
"object": "chat.completion",
"created": 1743770302,
"model": "grok-3-mini-fast-beta",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "101 multiplied by 3 equals 303.",
"reasoning_content": "First, the user asked: \"What is 101*3?\" This is a simple multiplication question.\n\nI need to calculate 101 multiplied by 3. Let me do that mentally: 101 times 3 is 303.\n\nTo double-check: 100 times 3 is 300, and 1 times 3 is 3, so 300 + 3 = 303. Yes, that's correct.\n\nAs a helpful assistant, I should respond clearly and directly. Since this is straightforward, I don't need to add extra fluff unless it's necessary.\n\nThe system prompt says: \"You are a helpful assistant that can answer questions and help with tasks.\" So, answering directly fits.\n\nI should ensure my response is polite and engaging, but keep it concise.\n\nPossible response: \"101 multiplied by 3 equals 303.\"\n\nI could make it a bit more conversational: \"Sure, let me calculate that for you. 101 times 3 is 303.\"\n\nSince the user might be testing basic math, I could explain briefly, but that might be overkill for such a simple operation.\n\nFinally, structure the response: Start with the answer, and if needed, add any follow-up.\n\nResponse: \"The result of 101 multiplied by 3 is 303.\"",
"refusal": null
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 32,
"completion_tokens": 10,
"total_tokens": 299,
"prompt_tokens_details": {
"text_tokens": 32,
"audio_tokens": 0,
"image_tokens": 0,
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 257,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"system_fingerprint": "fp_11dc627712"
}
}

Create Message

Create a message using the Anthropic-compatible messages API endpoint | key: createMessage

InputDefaultNotesExample
Additional Fields
code
additionalFields
Additional fields that are not supported by the action inputs. See [xAI API docs](https://docs.x.ai/docs/api-reference#messages-anthropic-compatible) for possible values.
Connection
connection
/ Required
connection
 
 
 
Max Tokens
string
/ Required
maxTokens
100
The maximum number of tokens to generate before stopping. The model may stop before the max_tokens when it reaches the stop sequence.
100
Messages
code
/ Required
messages
Input messages. See [xAI API docs](https://docs.x.ai/docs/api-reference#messages-anthropic-compatible) for possible values.
Model
string
/ Required
model
grok-3-fast-latest
Model name for the model to use. Obtainable [here](https://docs.x.ai/docs/models).
 

{
"data": {
"id": "4f224bfb-9d53-4c82-b40a-b7cd80831ec2",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello there! \"Hello, world\" is a classic, isn't it? Whether you're just saying hi or channeling your inner coder, I'm happy to greet you back"
}
],
"model": "grok-3-fast-beta",
"stop_reason": "max_tokens",
"stop_sequence": null,
"usage": {
"input_tokens": 9,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 32
}
}
}

Generate Image

Generate an image using xAI's image generation API | key: generateImage

InputNotesExample
Additional Fields
code
additionalFields
Additional fields that are not supported by the action inputs. See [xAI API docs](https://docs.x.ai/docs/api-reference#image-generations) for possible values.
Connection
connection
/ Required
connection
 
 
Model
string
/ Required
model
Model to be used.
grok-2-image
Number of Images
string
n
Number of images to generate.
1
Prompt
string
/ Required
prompt
The text prompt to generate an image from.
A serene landscape with mountains and a lake at sunset

{
"data": [
{
"url": "...",
"revised_prompt": "A high-resolution photograph of a cat perched on a branch in a lush, green tree during the daytime. The cat, possibly a tabby with distinctive fur patterns, is the central focus of the image, looking curiously forward with its fur slightly ruffled. The background features a serene park setting with other trees and a clear sky, ensuring no distractions from the main subject. The lighting is soft and natural, enhancing the realistic and calm atmosphere of the scene.<|separator|><|eos|>"
}
]
}

Get Model

Get details about a specific model | key: getModel

InputNotesExample
Connection
connection
/ Required
connection
 
 
Model ID
string
/ Required
modelId
The ID of the model to retrieve.
grok-3-fast-beta

{
"data": {
"id": "grok-3-fast-beta",
"created": 1743724800,
"object": "model",
"owned_by": "xai"
}
}

List Models

List all available models from xAI | key: listModels

InputNotes
Connection
connection
/ Required
connection
 

{
"data": [
{
"id": "grok-3-beta",
"created": 1743724800,
"object": "model",
"owned_by": "xai"
}
],
"object": "list"
}

Raw Request

Send raw HTTP request to xAI | key: rawRequest

InputDefaultNotesExample
Connection
connection
/ Required
connection
 
 
 
Data
string
data
The HTTP body payload to send to the URL.
{"exampleKey": "Example Data"}
File Data
string
Key Value List
fileData
File Data to be sent as a multipart form upload.
[{key: "example.txt", value: "My File Contents"}]
File Data File Names
string
Key Value List
fileDataFileNames
File names to apply to the file data inputs. Keys must match the file data keys above.
 
Form Data
string
Key Value List
formData
The Form Data to be sent as a multipart form upload.
[{"key": "Example Key", "value": new Buffer("Hello World")}]
Header
string
Key Value List
headers
A list of headers to send with the request.
User-Agent: curl/7.64.1
Max Retry Count
string
maxRetries
0
The maximum number of retries to attempt. Specify 0 for no retries.
 
Method
string
/ Required
method
The HTTP method to use.
 
Query Parameter
string
Key Value List
queryParams
A list of query parameters to send with the request. This is the portion at the end of the URL similar to ?key1=value1&key2=value2.
 
Response Type
string
/ Required
responseType
json
The type of data you expect in the response. You can request json, text, or binary data.
 
Retry On All Errors
boolean
retryAllErrors
false
If true, retries on all erroneous responses regardless of type. This is helpful when retrying after HTTP 429 or other 3xx or 4xx errors. Otherwise, only retries on HTTP 5xx and network errors.
 
Retry Delay (ms)
string
retryDelayMS
0
The delay in milliseconds between retries. This is used when 'Use Exponential Backoff' is disabled.
 
Timeout
string
timeout
The maximum time that a client will await a response to its request
2000
URL
string
/ Required
url
Input the path only (/models), The base URL is already included (https://api.x.ai/v1). For example, to connect to https://api.x.ai/v1/models, only /models is entered in this field.
/models
Use Exponential Backoff
boolean
useExponentialBackoff
false
Specifies whether to use a pre-defined exponential backoff strategy for retries. When enabled, 'Retry Delay (ms)' is ignored.