Grok (xAI)

Generate text completions using xAI's Grok models.

AI and MLAPI key5 actionsAll integrations

On this page
  1. Connect
  2. Call it from a workflow
  3. Actions (5)
  4. ask_grok
  5. categorize_text
  6. extract_data_from_text
  7. generate_image
  8. custom_api_call
  9. Details

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.

Workflow
// 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);
});
Try it from your agent
{
  "name": "integrations",
  "arguments": {
    "project_id": "<project-id>",
    "action": "call",
    "piece": "grok_xai",
    "piece_action": "ask_grok",
    "input": {
      "model": "<model>",
      "messages": []
    },
    "env": "dev"
  }
}
From another backend (connector proxy)
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.

InputTypeDescription
modelrequiredid (picked from your account)Grok model to use for generating the response.
messagesrequiredarrayConversation messages for multi-turn conversations.
quickPromptoptionallong textSimple text prompt for single-turn conversations. Ignored if Messages is provided.
systemMessageoptionallong textSystem message to set behavior and context.
imageUrloptionaltextImage URL for vision models. Works with quick prompt mode.
temperatureoptionalnumberControls randomness (0-2): 0 = deterministic, 1 = balanced, 2 = creative.
maxCompletionTokensoptionalnumberMaximum tokens for the response.
responseFormatoptionalone of "text" | "json_object" | "json_schema"Output format for the response.
jsonSchemaoptionallong textJSON schema for structured output (when response format is json_schema).
enableRealTimeSearchoptionalbooleanAllow Grok to search the web and X for current information.
searchModeoptionalone of "auto" | "on" | "off"How to handle real-time data search.
maxSearchResultsoptionalnumberMaximum number of search results to use (1-30).
searchSourcesoptionalids (picked from your account)Sources to search in.
toolsoptionalarrayFunctions the model can call.
toolChoiceoptionalone of "auto" | "none" | "required"How the model should use tools.
parallelToolCallsoptionalbooleanAllow model to call multiple tools simultaneously.
reasoningEffortoptionalone of "" | "low" | "high"How hard reasoning models should think (not for grok-4).
memoryKeyoptionaltextKeep conversation history across runs.

categorize_text

Categorize Text. Assign categories to input text based on custom or predefined labels.

InputTypeDescription
modelrequiredid (picked from your account)Grok model to use for text categorization.
textrequiredlong textText content to categorize.
categoriesrequiredarrayDefine the categories for classification.
allowMultipleoptionalbooleanText can be assigned to multiple categories.
includeConfidenceoptionalbooleanInclude confidence scores for each category.
customInstructionsoptionallong textAdditional instructions for categorization.
enableContextSearchoptionalbooleanSearch for additional context to improve categorization.
temperatureoptionalnumberControls randomness (0-2): 0 = deterministic, 1 = balanced, 2 = creative.
maxCompletionTokensoptionalnumberMaximum tokens for the response.
reasoningEffortoptionalone 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).

InputTypeDescription
modelrequiredid (picked from your account)Grok model to use for data extraction.
textrequiredlong textText to extract data from.
extractionPromptoptionallong textHow to extract the data.
fieldsrequiredarrayDefine the structured fields to extract from the text.
enableContextSearchoptionalbooleanSearch for additional context to improve extraction.
strictExtractionoptionalbooleanOnly extract explicitly present information.
temperatureoptionalnumberControls randomness (0-2): 0 = deterministic, 1 = balanced, 2 = creative.
maxCompletionTokensoptionalnumberMaximum tokens for the response.
reasoningEffortoptionalone of "" | "low" | "high"How thoroughly to analyze the text.
includeConfidenceoptionalbooleanInclude confidence scores for extracted fields.

generate_image

Generate Image. Create images from text prompts using Grok's image generation.

InputTypeDescription
promptrequiredlong textDetailed description of the image you want to generate.
modelrequiredid (picked from your account)Image generation model to use.
numberOfImagesoptionalnumberNumber of images to generate (1-10).
responseFormatoptionalone of "url" | "b64_json"Format of the generated images.

custom_api_call

Custom API Call. Make a custom API call to a specific endpoint

InputTypeDescription
urlrequiredobject (depends on other props)url
methodrequiredone of "GET" | "POST" | "PATCH" | "PUT" | "DELETE" | "HEAD"Method
headersrequiredobjectAuthorization headers are injected automatically from your connection.
queryParamsrequiredobjectQuery Parameters
body_typeoptionalone of "none" | "json" | "form_data" | "raw"Body Type
bodyoptionalobject (depends on other props)Body
response_is_binaryoptionalbooleanEnable for files like PDFs, images, etc.
failsafeoptionalbooleanNo Error on Failure
timeoutoptionalnumberTimeout (in seconds)
followRedirectsoptionalbooleanFollow 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