Grok (xAI)
Generate text completions using xAI's Grok models.
On this page
Connect
Auth type: API key (secret_text). Paste the API key (or token) from the provider's settings into the connect dialog. It is encrypted at rest and only decrypted on the server when an action runs.
- In the editor: Backend panel, Integrations tab, then Connect. This connects it for the project.
- For every project in a workspace: Workspace settings, Integrations.
- Owners and admins choose which integrations members may connect in the admin panel (Integrations tab), and can attach their own OAuth app there.
Call it from a workflow
Pass the action name and its input. The call resolves with { success, output, error? }; a missing connection resolves with success false and the reason. See ctx.integrations.invoke and ctx.integrations.call.
// .workflow.js (native ctx)
export async function run(ctx) {
const res = await ctx.integrations.invoke("grok_xai", "ask_grok", {
"model": "<model>",
"messages": []
});
if (!res.success) throw new Error(res.error);
ctx.log.info("Grok (xAI) answered", { output: res.output });
}// defineWorkflow module (@app/sdk ctx)
import { defineWorkflow } from "@app/sdk";
export default defineWorkflow({
id: "grok-xai-ask-grok",
name: "Grok (xAI): Ask Grok",
description: "Calls Grok (xAI) when a row is created.",
trigger: { type: "entity_event", entity: "tickets", event: "created" },
async run(ctx, event) {
const res = await ctx.integrations.call("grok_xai", {
"action": "ask_grok",
"model": "<model>",
"messages": []
}) as { success: boolean; error?: string };
if (!res.success) throw new Error(res.error);
},
});curl -X POST "$APP_ORIGIN/__appbricx/connector-proxy/grok_xai/ask_grok" \
-H "Authorization: Bearer $APP_KEY" \
-H "content-type: application/json" \
-d '{"props":{"model":"<model>","messages":[]}}'Actions
ask_grokin catalog
Ask Grok. Send prompts to Grok with real-time search, tools, and structured outputs.
| Input | Type | Description |
|---|---|---|
modelrequired | id (picked from your account) | Grok model to use for generating the response. |
messagesrequired | array | Conversation messages for multi-turn conversations. |
quickPromptoptional | long text | Simple text prompt for single-turn conversations. Ignored if Messages is provided. |
systemMessageoptional | long text | System message to set behavior and context. |
imageUrloptional | text | Image URL for vision models. Works with quick prompt mode. |
temperatureoptional | number | Controls randomness (0-2): 0 = deterministic, 1 = balanced, 2 = creative. |
maxCompletionTokensoptional | number | Maximum tokens for the response. |
responseFormatoptional | one of "text" | "json_object" | "json_schema" | Output format for the response. |
jsonSchemaoptional | long text | JSON schema for structured output (when response format is json_schema). |
enableRealTimeSearchoptional | boolean | Allow Grok to search the web and X for current information. |
searchModeoptional | one of "auto" | "on" | "off" | How to handle real-time data search. |
maxSearchResultsoptional | number | Maximum number of search results to use (1-30). |
searchSourcesoptional | ids (picked from your account) | Sources to search in. |
toolsoptional | array | Functions the model can call. |
toolChoiceoptional | one of "auto" | "none" | "required" | How the model should use tools. |
parallelToolCallsoptional | boolean | Allow model to call multiple tools simultaneously. |
reasoningEffortoptional | one of "" | "low" | "high" | How hard reasoning models should think (not for grok-4). |
memoryKeyoptional | text | Keep conversation history across runs. |
categorize_textin catalog
Categorize Text. Assign categories to input text based on custom or predefined labels.
| Input | Type | Description |
|---|---|---|
modelrequired | id (picked from your account) | Grok model to use for text categorization. |
textrequired | long text | Text content to categorize. |
categoriesrequired | array | Define the categories for classification. |
allowMultipleoptional | boolean | Text can be assigned to multiple categories. |
includeConfidenceoptional | boolean | Include confidence scores for each category. |
customInstructionsoptional | long text | Additional instructions for categorization. |
enableContextSearchoptional | boolean | Search for additional context to improve categorization. |
temperatureoptional | number | Controls randomness (0-2): 0 = deterministic, 1 = balanced, 2 = creative. |
maxCompletionTokensoptional | number | Maximum tokens for the response. |
reasoningEffortoptional | one of "" | "low" | "high" | How thoroughly to analyze the text. |
extract_data_from_textin catalog
Extract Data From Text. Extract structured data fields from unstructured text (e.g., names, addresses, dates).
| Input | Type | Description |
|---|---|---|
modelrequired | id (picked from your account) | Grok model to use for data extraction. |
textrequired | long text | Text to extract data from. |
extractionPromptoptional | long text | How to extract the data. |
fieldsrequired | array | Define the structured fields to extract from the text. |
enableContextSearchoptional | boolean | Search for additional context to improve extraction. |
strictExtractionoptional | boolean | Only extract explicitly present information. |
temperatureoptional | number | Controls randomness (0-2): 0 = deterministic, 1 = balanced, 2 = creative. |
maxCompletionTokensoptional | number | Maximum tokens for the response. |
reasoningEffortoptional | one of "" | "low" | "high" | How thoroughly to analyze the text. |
includeConfidenceoptional | boolean | Include confidence scores for extracted fields. |
generate_imagein catalog
Generate Image. Create images from text prompts using Grok's image generation.
| Input | Type | Description |
|---|---|---|
promptrequired | long text | Detailed description of the image you want to generate. |
modelrequired | id (picked from your account) | Image generation model to use. |
numberOfImagesoptional | number | Number of images to generate (1-10). |
responseFormatoptional | one of "url" | "b64_json" | Format of the generated images. |
custom_api_call
Custom API Call. Make a custom API call to a specific endpoint
| Input | Type | Description |
|---|---|---|
urlrequired | object (depends on other props) | url |
methodrequired | one of "GET" | "POST" | "PATCH" | "PUT" | "DELETE" | "HEAD" | Method |
headersrequired | object | Authorization headers are injected automatically from your connection. |
queryParamsrequired | object | Query Parameters |
body_typeoptional | one of "none" | "json" | "form_data" | "raw" | Body Type |
bodyoptional | object (depends on other props) | Body |
response_is_binaryoptional | boolean | Enable for files like PDFs, images, etc. |
failsafeoptional | boolean | No Error on Failure |
timeoutoptional | number | Timeout (in seconds) |
followRedirectsoptional | boolean | Follow redirects |
Details
- Id
grok_xai- Category
- AI and ML
- Tags
- ai, xai, grok, llm
- Package
@activepieces/piece-grok-xai@0.1.4- Tier
- Community