xAI Grok smart home integration, free and open source

Run the Gladys assistant on xAI Grok models with your own xAI API key.
Overview
This integration runs the assistant of Gladys on the Grok models of xAI, through the official xAI API (Responses API) and your own API key. Once you choose it in Settings → Artificial Intelligence, every AI request of Gladys goes to Grok: the chat and the devices it controls, the scenes it creates, the "ask the AI" scene action and the weekly digest. It works without a Gladys Plus account: you pay xAI directly, per use.
It also adds a scene action that asks Grok with a web or X search (news, traffic, what people say about an event), two scene triggers (the assistant fails, the assistant answers again) and a dashboard widget of your consumption, with the cost xAI bills for each answer.
Not affiliated with xAI. Not tested with a real xAI key yet: feedback welcome.
Prerequisites
- Gladys Assistant 5.3.0 or later.
- An account on the xAI console with credits (Billing), and an API key: API Keys, Create API key. The key starts with
xai-. - Costs: billed per token, in US dollars. Grok 4.7 costs $2 per million input tokens and $6 per million output tokens (reasoning included), Grok 4.3 $1.25 / $2.50; cached input is cheaper. A chat turn costs a fraction of a cent. The web search action adds $5 per 1,000 web searches or X posts read. Set a spending limit in the console: the integration then stops cleanly when it is reached.
- Your data: xAI does not train on API data without your permission, but keeps requests and answers 30 days for abuse audits, unless zero data retention (ZDR) is on for your team. The integration sends every request with storage off (
store: false), so the answers cannot be fetched again later. - What leaves your home: every chat message, the history, the tools Gladys offers and their results (the state of the devices Grok reads), the chat images and the questions of the search action go to xAI over HTTPS. The answers control your devices and create scenes.
Configuration
| Field or button | Default | Meaning |
|---|---|---|
| xAI API key | — | Required. Never shown again, never logged |
| Chat model | Grok 4.7 | Answers the chat, creates scenes, writes the weekly digest, runs the search action |
| Router model | Grok 4.3 | Sorts every message before the answer and must reply within 20 seconds (reasoning off) |
| Other model id | — | Only when a model is set to "Other model": the exact API id (it must call tools in Responses) |
| Reasoning of the chat model | Low | More reasoning, better scenes, slower and costlier answers |
| Maximum answer length (tokens) | 8000 | The visible text only: xAI does not count the reasoning in it |
| Test the connection | — | One short answer from each model with its time; spends a few tokens |
The status of the configuration screen says whether xAI accepts the key and both models, without spending a token. Reading a model does not prove that the team can pay (no credit left, spending limit): Test the connection does.
Usage
- Integrations → xAI Grok → Configuration: paste the API key, keep the default models, press Test the connection.
- Settings → Artificial Intelligence: choose xAI Grok.
- Talk to Gladys in the chat: "turn on the living room", "what is the temperature in the bedroom?", "create a scene that closes the shutters at sunset".
Choosing the models
Prices per million tokens, input / output, on 3 December 2026:
- Grok 4.7 (default for the chat, $2 / $6): the strongest, best at calling tools and creating scenes. It always reasons (low at least).
- Grok 4.6 ($2 / $6): the previous version, same price.
- Grok 4.3 (default router, $1.25 / $2.50): faster and cheaper, the only one that can turn reasoning off; less reliable to create scenes.
- Grok 4.20 (non-reasoning) (router, $1.25 / $2.50): no reasoning at all.
- Other model: a newer model or an alias such as
grok-4.7-latest. If it refuses the reasoning parameters, the integration sends it without them from then on.
Grok 4.7 and 4.6 cannot turn reasoning off: None becomes low for them. The router always uses the least reasoning its model accepts. Grok gives its reasoning back in an encrypted form, which the integration returns with the results of the tools of the same turn, so the model keeps its train of thought between two device actions.
Dashboard widget
The Grok usage widget shows the requests, tokens and cost of the day, the cost of the month, the errors of the day, the tokens per day over 30 days, whether Grok answers, the models, the last request and the last error. The cost is the one xAI returns with each answer (web searches included), in US dollars; the usage page of the xAI console stays the reference for the bill.

Scenes
- Action "Grok: ask with web or X search": a question (scene variables allowed), where to search (the web, the posts of X, or both), optionally up to 5 websites or 20 X accounts and extra instructions. It returns a short answer in plain text and its sources (one URL per line), to use in a message or a spoken notification. At most 5 search turns per question.
- Trigger "xAI: the assistant fails": once per failure (key refused, credits or spending limit, rate limit, model unavailable, API unreachable, too slow, xAI error), with the kind, the message, the request and the model.
- Trigger "xAI: the assistant answers again": the first answer after a failure, with the minutes of failure.
Examples:
- Every morning at 7:00, ask "What are the three main news of the day in France?" on the web, then send the answer by Telegram.
- When the river level sensor goes above its alert threshold, ask "What do @VigiCrues and the local authorities say about the floods today?" on X, then send the answer and its sources.
- When the assistant fails because of credits or the spending limit, send a message to the administrator; when it answers again, send another one with the minutes of failure.
Troubleshooting
- "xAI refused the API key": copy the key again from the API Keys page; a revoked or blocked key gives the same message. xAI answers a wrong key with an HTTP 400 "Incorrect API key provided".
- "xAI refuses to run …: no credit left or spending limit reached": add credits in Billing, or raise the spending limit. Waiting does not help: the integration does not retry.
- "Rate limit reached": the limits depend on the tier of the team, which rises with what it has spent. A chat turn makes at least two requests.
- "… is not available to this API key": the model id is wrong, the model was retired, or it is not open to your team or region; choose another one.
- The chat answers without doing anything: keep Grok 4.7 with low or medium reasoning; Grok 4.3 is less reliable with many tools.
- "The answer was cut at max_tokens": raise the maximum answer length.
- "content_filter": xAI's safety systems blocked the request or the answer; rephrase it.
- The search action answers with no source: the question did not need a search, or the websites or accounts you chose had nothing; widen them.
- Logs: Settings → Supervision, the logs of the integration. Never share your API key.
Configuration settings
These are the settings xAI Grok asks for in its configuration screen in Gladys.
| Setting | Type | Required | Description |
|---|---|---|---|
| Getting started | section | No | The assistant answers through the xAI API, billed per use on your xAI team (prepaid credits or invoice): create an API key on console.x.ai, paste it below, then select this integration in Settings, Artificial Intelligence. xAI then sees every chat message, the history, the state of the devices Grok reads and the chat images. |
| Costs and privacy | section | No | xAI does not train on API data without your permission, but keeps requests and answers 30 days for abuse audits, unless zero data retention is on for the team. Every chat message also runs the router; the widget shows the cost xAI bills for each answer. |
| xAI API key | secret | Yes | Created on console.x.ai, in API Keys (it starts with xai-). It stays in Gladys and is never shown again nor logged. |
| Chat model | select | Yes | Answers the chat, creates the scenes, writes the weekly digest and runs the web search action. Grok 4.7 is the strongest ($2 / $6 per million tokens in / out); Grok 4.3 costs about half but is less reliable to create scenes. |
| Router model | select | Yes | Sorts every chat message before the answer, and must reply within 20 seconds: a model without reasoning fits best. Grok 4.3 runs it with reasoning off, fast and cheap. |
| Other model id | string | No | Only for “Other model”: the exact API id of a Grok model (a newer model, an alias such as grok-4.7-latest…). It must call functions through the Responses API. |
| Reasoning of the chat model | select | Yes | More reasoning gives better scenes but slower, costlier answers. Only Grok 4.3 can turn it off: “None” becomes low for the others. |
| Maximum answer length (tokens) | number | No | The visible text only: xAI does not count the reasoning in it. Raise it if the logs say an answer hit max_tokens. |
How to install xAI Grok in Gladys
- In Gladys, open Integrations: xAI Grok appears in the catalog, next to the native integrations, with a community badge.
- Click Install. Gladys pulls the Docker image (
ghcr.io/william-de71/gladys-xai-grok:0.1.0), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration). - Open the Configuration screen of the integration, fill in the settings, and save.
- You can also install it directly from its repository URL: https://github.com/William-De71/gladys-xai-grok.
xAI Grok requires Gladys >=5.3.0. The catalog inside Gladys refreshes every hour, so a new version becomes available at most one hour after its release.
Not running Gladys yet? It is free and open source: follow the installation guide to get started.
About external integrations
xAI Grok is an external integration: a community integration packaged as a Docker container and published on GitHub, that Gladys installs in one click and runs in a sandbox isolated from its core. It is published and maintained by William-De71, not by the Gladys core team.
- Browse all integrations, native and community
- Build and publish your own external integration
- Source code on GitHub — source of this documentation