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

Changelog ↓

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

Your xAI Grok API key.

xai-XqaU...

Data Sources

Select Model

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

InputNotesExample
Connection

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

Actions

Create Chat Completion

Create a chat completion using xAI Grok | key: createChatCompletion

InputNotesExample
Additional Fields

Additional fields that are not supported by the action inputs. See xAI API docs for possible values.

Connection
Messages

A list of messages that make up the the chat conversation. Different models support different message types, such as image and text.

Model

Model name for the model to use. Obtainable here.

grok-2-latest
Stream

If set, partial message deltas will be sent.

false
Temperature

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

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

InputNotesExample
Additional Fields

Additional fields that are not supported by the action inputs. See xAI API docs for possible values.

Connection
Max Tokens

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

Input messages. See xAI API docs for possible values.

Model

Model name for the model to use. Obtainable here.

grok-3-fast-latest

{
"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

Additional fields that are not supported by the action inputs. See xAI API docs for possible values.

Connection
Model

Model to be used.

grok-2-image
Number of Images

Number of images to generate.

1
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
Model ID

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

InputNotesExample
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

InputNotesExample
Connection
Data

The HTTP body payload to send to the URL.

{"exampleKey": "Example Data"}
File Data

File Data to be sent as a multipart form upload.

[{key: "example.txt", value: "My File Contents"}]
File Data File Names

File names to apply to the file data inputs. Keys must match the file data keys above.

Form Data

The Form Data to be sent as a multipart form upload.

[{"key": "Example Key", "value": new Buffer("Hello World")}]
Header

A list of headers to send with the request.

User-Agent: curl/7.64.1
Max Retry Count

The maximum number of retries to attempt. Specify 0 for no retries.

0
Method

The HTTP method to use.

Query Parameter

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

The type of data you expect in the response. You can request json, text, or binary data.

json
Retry On All Errors

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.

false
Retry Delay (ms)

The delay in milliseconds between retries. This is used when 'Use Exponential Backoff' is disabled.

0
Timeout

The maximum time that a client will await a response to its request

2000
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

Specifies whether to use a pre-defined exponential backoff strategy for retries. When enabled, 'Retry Delay (ms)' is ignored.

false

Changelog

2025-07-07

Initial release of xAI Grok component with AI chat completion, message creation, image generation, and model management capabilities.