xAI Conversation

xAI Conversation

Bringing the power of xAI Grok to your Home Assistant.

GitHub Release
Home Assistant
hacs
License: GPL v3


Conversation Agent

A complete conversation agent integration for Home Assistant that offers multiple ways to manage your conversation data and interact with your smart home through Grok.

Assist Chat


:rocket: Installation

Via HACS (Recommended)

  1. Open HACS in Home Assistant.
  2. Search for “xAI Conversation” and click Download.
  3. Restart Home Assistant.
  4. Go to Settings → Devices & Services → Add Integration → xAI Conversation.
  5. Enter your xAI API key (get one at x.ai).

Install via HACS

Configure Integration

Full changelog → Releases · pajeronda/xai_conversation · GitHub


:sparkles: Key Features

Feature Description
Conversation Continuity When using Server-side Memory, chats continue seamlessly across any device configured with your user account (Smartphone, Tablet, PC, etc.).
Location Context Set your home location (e.g., “Rome, IT”) to help Grok with local searches like weather and news. Leave empty to use the Home Assistant time zone instead.
User Recognition Enable “Include username in messages” so Grok can identify and address you personally by your person entity name (or user display name as fallback).

:counterclockwise_arrows_button: Operational Modes

Select the best balance between privacy, cost, and efficiency:

Mode Memory Location Privacy Cost Best For
Server-side Memory (default) xAI Cloud Standard Lowest Efficiency, speed, and long-running conversations.
Zero Data Retention (ZDR) Local blob (Encrypted) Maximum Medium Privacy-focused context preservation (requires reasoning model).
Local Chatlog Home Assistant Standard Highest Full local history control with stateless turn-by-turn processing.

NOTE

  • Automatic Model Selection: When ZDR is enabled, the integration automatically selects a compatible reasoning model to correctly re-initialize the conversation from encrypted state blobs.
  • Local Chatlog is active when both Server-side Memory and Zero Data Retention are disabled.

:hammer_and_wrench: Interaction Modes

Grok acts as an advanced ASR/NLU orchestrator, providing three distinct ways to interact with your Home Assistant instance:

Mode Description
Intelligent Pipeline (Default) Leverages the Home Assistant Intent Pipeline. Works flawlessly with official and custom intents. Automatically falls back to Tool Control if needed to guarantee a premium experience.
Tool Control Direct interaction via Tool Calling. Use Home Assistant Standard Tools or Extended Tools (YAML).
Chat Only A pure conversational experience. Chat with Grok for general knowledge or assistance without interacting with Home Assistant entities.

NOTE

  • In the configuration agent options:

    • Intelligent Pipeline: Enabled by default, requires “Allow smart home control” to be ON.
    • Tool Control: Active when “Allow smart home control” is ON and “Enable Intelligent Pipeline” is OFF.
    • Chat Only: Active when “Allow smart home control” is OFF.
  • Switching between these modes starts a new conversation with a separate history.

  • The configuration page may automatically reload when toggling certain options (like Operational Modes, Zero Data Retention, or Memory Settings) to correctly apply internal logic and dynamic fields. This is expected behavior.

:wrench: Extra Tools

Extended Tools (YAML)

This component supports custom tools in YAML format, fully compatible with Extended OpenAI Conversation. Enable and configure them in the integration’s global configuration settings, then activate them per conversation agent settings.

Home Assistant Extended Tools

This integration extends the standard Home Assistant tools with additional capabilities for controlling helpers, scripts, and automations. These tools are automatically available when “Allow smart home control” is enabled and you are using the standard Home Assistant tools.

Tool Description
HassSetInputNumber Sets the value of an input_number entity (volume, temperature, etc.)
HassSetInputBoolean Turns an input_boolean entity on or off (toggles, flags)
HassSetInputText Sets the text value of an input_text entity
HassRunScript Executes a Home Assistant script
HassTriggerAutomation Triggers a Home Assistant automation
HassPhotoAnalysis Have them describe to you what your cameras see
IntentExecution Your custom intents become tools!

xAI Tools

Enable Live Search (web) and 𝕏 Search in the conversation agent options for real-time information with citations (if you enable citations in the conversation agent options).


Stateless data generation

:gear: AI Task Integration

Stateless data generation, smart automations, and image generation.

:thought_balloon: ASK (xai_conversation.ask)

A highly versatile, stateless service designed for one-shot queries. Similar to AI Task, it doesn’t maintain history, but it allows you to override the model, temperature, and live search settings “on the fly” for each individual call. It returns the response directly in a variable.

Use Case: Ideal for processing raw sensor data, distilling information from the web, or any task that requires a specific Grok model different from your default assistant.

service: xai_conversation.ask
data:
  instructions: "{{ instructions }}"
  input_data: "{{ data_to_send }}"
  model: grok-4-1-fast-non-reasoning  # (optional)
  temperature: 0.7  # (optional)
  max_tokens: 1000  # (optional)
  reasoning_effort: "low"  # (optional) - for reasoning models
  live_search: "web search"  # (optional) - web search, x search, or full
  show_citations: true  # (optional)
response_variable: output_xai

:camera_with_flash: Photo Analysis (xai_conversation.photo_analysis)

A stateless vision service to analyze snapshots or external images. Similarly to the ask service, it is fully configurable per call and can be integrated into Automations, Scripts, or used for manual inspection via Developer Tools.

service: xai_conversation.photo_analysis
data:
  prompt: "Is there a package at the front door?"
  images:
    - /config/www/doorbell_snapshot.jpg
  temperature: 0.1  # (optional)
  top_p: 1.0        # (optional)

:wrench: Maintenance

Services and Sensors for model, price cost, system health, resetting stats, or clearing history.

:bar_chart: Real-time Monitoring

Detailed sensors for:

  • model costs
  • token counts
  • cache efficiency
  • xAI Server tool invocations
  • notifications for new model releases.

:hammer_and_wrench: Manage Sensors

Forcefully refresh data or reset counters. Primarily used via Developer Tools or triggered by Automations.

service: xai_conversation.manage_sensors
data:
  reload_pricing: true #(or false) - Force update models and pricing from xAI
  reset_stats: false #(or true) - Reset all token and cost sensors to zero

:broom: Clear Memory

Clear conversation history for specific users or devices. Use it in Developer Tools for maintenance or triggered by Automations.

service: xai_conversation.clear_memory
data:
  user_id: person.admin  # Clear memory for a specific person
  include_server: true   # Also delete history from xAI servers

:warning: Deprecation Notice: Grok Code Fast

The Grok Code Fast service and the associated card are now unsupported (available up to release v2.2.1).

We recommend moving to the new and much more powerful AI Code Task integration:

GitHub

Install via your HACS instance.

AI Code Task is an agnostic simple IDE provider in a Lovelace card for code generation. It provides a superior workflow for modifying and generating YAML, Jinja2 templates, Python scripts, and more with an integrated pro editor.

:handshake: Contributing & Support

Legal Notes

  • This is a custom component for Home Assistant developed by @pajeronda

  • This custom component is released under the GNU General Public License v3.0

  • This custom component uses the official xAI Python SDK

  • API Usage: This custom component requires an active xAI account and a valid API key. Use of the xAI API is subject to xAI’s terms of service.

  • Trademarks: xAI, Grok, and related logos are registered trademarks of xAI Corp. This custom component is an unofficial integration for Home Assistant and is not affiliated with, sponsored by, or endorsed by xAI Corp.

4 Likes

:bullseye: Overview

This release significantly improves reliability and performance of the integration, with special focus on optimization for resource-constrained devices (Raspberry Pi, Proxmox VMs) and critical bug fixes.


:sparkles: What’s New

:rocket: Performance Improvements

  • Separate API vs Local Timing: Now you can see how much time the xAI API takes vs local processing
    • Helps identify if slowness comes from the API or your system
    • Visible in INFO logs chat_start and chat_end with api_time and local_process_time
  • Faster Operations: Save operations (tokens, memory) no longer block conversations
    • Everything is saved in background while you continue talking to the assistant
    • Less waiting time between voice commands
  • Reduced System Load: Optimizations for Raspberry Pi and low-power devices
    • Reduced CPU usage when not necessary
    • Better log handling (no resource waste when logging is disabled)

v2.0.0

December 9, 2025 Update :sparkles:

:christmas_tree: Christmas Release Changelog

This release introduces significant changes to the core architecture to improve scalability, maintainability, and feature robustness.

  1. Gateway Refactoring: XAIGateway is now centralized and entity-agnostic. It manages the configuration for all services.
  2. Tools Refactoring: Added local custom tools to trigger automations, start scripts, handle binary/text/number input, and added xAI Agent Tools: web_search, x_search, and code_execution.
  3. Services Refactoring: New TokenStats class for better separation of concerns between Manager → Storage → Presentation layers.
  4. Billing Tracking: Implemented xAI tool consumption tracking within TokenStats and created the XAIServerToolUsageSensor sensor.
  5. New Model Notifications: Persistent notifications when xAI releases new models. It will be directly available in the services config flow.
  6. I/O Optimization: Minimized disk I/O operations.
  7. Config Flow & UI: Updated live search options, added a boolean option “Show citations in chat” when using xAI tools, and added other technical parameters to the xAI Token Sensors config flow.

v2.1.0

December 13, 2025 Update :sparkles:

New xai_conversation.ask

xai_conversation.ask service allowing stateless LLM queries with raw input data and system instructions, returning the response directly in a variable. It stems from my need to have bulletins on various services, such as the weather, processed into natural language by the LLM.

   service: xai_conversation.ask
   data:
     max_tokens: 800
     temperature: 1
     instructions:  "{{ instructions }}"
     input_data: "{{ data_to_send }}"
   response_variable: output_ai

Full changelog: Release v2.1.0 · pajeronda/xai_conversation · GitHub

Release 2.2.0 :rocket:

A special tribute to jekalmin for creating one of the most appreciated AI integrations on Home Assistant.

:hammer_and_wrench: Extended Tools Support

We are excited to introduce full support for Extended Tools! You can now define custom tools using the YAML format from the Extended OpenAI Conversation integration.

Global Configuration: Define your tools once in the integration settings.
Per-Agent Control: Enable Extended Tools for specific agents while keeping others standard.
Full Compatibility: Supports scripts, templates, and advanced logic directly from Home Assistant.

:high_voltage: Performance & Optimization

This release brings significant under-the-hood improvements to make the integration faster and more responsive:
Faster Execution: Optimized how tools are called and managed.
Streamlined Core: Refactored internal code for better stability and lower resource usage.

:broom: Improvements

Better Localization: Fixed issues with translation files for a smoother multilingual experience.
Reliability: Updated internal dependencies to ensure rock-solid compatibility with Home Assistant.

Full Changelog: Release v2.2.0 · pajeronda/xai_conversation · GitHub

v3.0.0

This release redefines the foundations: redesigned architecture, more responsive services, and an optimized processing pipeline to leverage Grok to its full potential.

:warning: Breaking Change: Grok Code Fast Deprecation

The Grok Code Fast service and its related Lovelace card are no longer supported (available until version v2.2.1).

We recommend switching to the new and more powerful AI Code Task integration, which offers a complete IDE environment for code generation:

GitHub Repository

Install via your HACS instance.


:locked: New Features and Privacy

  • Zero Data Retention (ZDR): introduced ZDR mode that ensures maximum privacy by completely eliminating history storage on xAI servers (managed locally via encrypted blob).
  • Home Location: added a new optional field to define the home location, allowing Grok to better answer questions about weather or local news, for example.

:hammer_and_wrench: Stateless Services Reorganization

  • Improvements to ask and photo_analysis services: added the ability to pass optional parameters (model, temperature, etc.) directly from the service call.
  • xAI Task (AI Task) optimization: subsystem reorganized for faster processing speed.
  • Image Handling: added new modes for sharing image files, both internal to Home Assistant and external (via URL).

:globe_showing_europe_africa: Translations and Languages

  • Romanian (RO): introduced complete Romanian language translation.
  • English Fallback: configured English as the default language for all untranslated texts in other languages.

:wrench: Internal Architecture

  • The monolithic core has been decomposed into specialized modules to improve maintainability, testability, and overall performance, allowing Grok to respond faster and more accurately.

  • Updated the README.md file to better reflect the current structure and features of the add-on.


:star: Like this project? Leave a star on GitHub to support it!

:bug: Found a bug or have suggestions? Report it by opening an issue!

:folded_hands:t2: Thanks to user G8YTZ for their collaboration.


Full Changelog: Comparing v2.2.1...3.0.0 · pajeronda/xai_conversation · GitHub