Grok (xAI)
Generate text completions using xAI's Grok models.
On this page
Connect
Auth type: API key (secret_text). Pass the provider's API key or token as the connection's credential. It is sealed at rest and only opened on the server when an action runs.
- From your agent: integrations {action: "connect", piece, credentials, env} stores the credentials for dev, prod or all. Answers name the fields, never the values.
- Or set the integration's project secrets with the secrets tool (SLACK_BOT_TOKEN, DISCORD_WEBHOOK_URL, TELEGRAM_BOT_TOKEN, TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN …): a call uses the connection, else those secrets. integrations {action: "catalog", piece} lists which ones work.
- Try one action now with integrations {action: "call", piece, piece_action, input}. It really sends.
Call it from a workflow
step.ctx.integrations.invoke("grok_xai", action, input) resolves with the provider's answer and rejects when Grok (xAI) isn't connected or refuses. Wrap it in step.run so a retry sends once. See step.ctx. Its actions run through the integration runner, which the server's operator turns on: integrations {action: "catalog", piece: "grok_xai"} says whether yours can call it.
// workflows/notify.ts: call Grok (xAI) when a booking is confirmed
import { on } from "@appbricx/workflows";
export const tellGrokXai = on.transition("booking", "status", "confirmed", async (_event, step) => {
// Recorded once: a retry doesn't send it twice. Rejects when Grok (xAI) isn't connected.
const output = await step.run("Grok (xAI)", () =>
step.ctx.integrations.invoke("grok_xai", "ask_grok", {
"model": "<model>",
"messages": []
}),
);
step.ctx.log("Grok (xAI) answered", output);
});{
"name": "integrations",
"arguments": {
"project_id": "<project-id>",
"action": "call",
"piece": "grok_xai",
"piece_action": "ask_grok",
"input": {
"model": "<model>",
"messages": []
},
"env": "dev"
}
}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_grok
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_text
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_text
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_image
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- Runs
- Through the integration runner