Grok Integration
This module connects Drupal to xAI's Grok AI services, enabling text generation, chat, and image/video creation directly within Drupal. It supports multimodal prompts, function calling, and optional xAI-hosted tools like web search, with API keys managed securely.
Grok Integration connects Drupal's AI module to xAI. It provides Grok chat and multimodal models, Grok Imagine image and video generation, voice operations, hosted tools, Drupal AI Explorer enhancements, and best-effort cost estimates.
The xAI API key is stored in Drupal's Key module, not in exported configuration. This is an unofficial community integration and is not affiliated with or endorsed by xAI.
Supported Drupal AI operations
- Chat, streaming chat, vision input, function tools, and structured output
- Text to Image and Image to Image
- Text to Video and Image to Video
- Text to Speech and Speech to Text
- Image Classification
- Model-based Moderation
- Grok Collections knowledge-base search through xAI Collections Search. The optional Grok Documents (
grok_doc) module adds Drupal administration for registering existing Collections, uploading documents, and queued bulk ingestion.
Ordinary requests use Chat Completions. Requests that enable xAI-hosted tools use the Responses API automatically. Moderation is a probabilistic Grok assessment, not a dedicated safety or compliance endpoint.
Drupal AI Explorer enhancements
Compatible Explorers include operation-specific example prompts, token and reasoning usage, xAI-reported or estimated request cost, shared image inputs, and optional generated audio/video saving to Drupal Media. Administrators can customize or disable the example prompts from the provider configuration form.
Image operations can use an upload, the bundled example image, or a compatible Drupal Media item. The optional Media Library Form Element module provides a visual selector; entity autocomplete remains available without it.
Cost estimation
When xAI reports usage.cost_in_usd_ticks, that value is shown. Otherwise, Grok Integration estimates cost from an editable, versioned pricing schedule covering tokens, cached and long-context input, images, video, speech characters, and transcription hours. Estimates are informational and may differ from the final xAI invoice.
Optional xAI-hosted tools
- Web Search
- X Search
- Code Interpreter
- Collections Search
- Allowlisted remote MCP servers
Hosted tools are disabled by default at both site and request level. Remote MCP servers require HTTPS and an explicit allowed-tools list. Grok Integration includes Collections Search, but it does not itself manage collections or documents. Install the separately maintained Grok Documents module when Drupal needs collection registration, document upload, or queued bulk ingestion.
Installation and configuration
Install the current beta with Composer:
composer require 'drupal/grok:^1.0@beta' drush en grok
Create a Drupal Key entity containing an xAI API key, then configure Grok Integration at /admin/config/ai/providers/grok. Use Test connection and load models to verify credentials and discover models available to the key. When discovery finds a newer numbered Grok family, Drupal AI's AI Capabilities from Installed Providers section offers a confirmed action to update older Grok defaults. Newly published pricing rows are also merged into the provider form for review without overwriting custom pricing.
Drupal 11.2+ sites can alternatively apply the included recipe after Composer installation:
vendor/bin/dr recipe web/modules/contrib/grok/recipes/grokUpgrading from alpha8 or earlier
The machine name changed from grok_ai_provider to grok in alpha9. Export or record the existing settings, uninstall the former Grok AI Provider module, update the code, enable grok, and restore the settings.
Requirements
- PHP 8.1 or later
- Drupal 10.6 or Drupal 11.2+
- AI 1.4 or later
- Key 1.22 or later
- An xAI API key
Security and privacy
Prompts, uploaded media, generated content, and enabled hosted-tool context are sent to the configured API endpoint. Web Search, X Search, Code Interpreter, Collections Search, and remote MCP can send context to additional services. Review data-residency, retention, and privacy requirements before enabling them.
Responses API storage is disabled by default. A custom API base URL receives the configured xAI key and must be trusted. Grok Documents should use a separate, least-privilege Management API key for document operations.
Report security issues privately through the process in the project's SECURITY.md; do not publish secrets or customer data in an issue.
Translations
Grok Integration uses Drupal's String Translation API and includes basic packaged translations for Arabic, German, Spanish, French, Hindi, Japanese, Portuguese, Russian, Swahili, and Simplified Chinese. Community translations can be contributed through Drupal localization.
Project status
The 1.0.x beta series is intended for compatibility and release-candidate testing across Drupal 10.6 and Drupal 11.2+. Please report reproducible defects with Drupal, PHP, AI module, Key module, and Grok Integration versions.
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 1.0.0-beta5 | Pre-release | 10–11 | Final planned beta: native PDF chat and PDF Explorer, plus comprehensive Grok AI capability configuration. | Aug 26, 2026 | |
| 1.0.0-beta4 | Pre-release | 10–11 | Adds automatic Grok model-family upgrades and trusted pricing synchronization. | Aug 16, 2026 | |
| 1.0.0-beta2 | Pre-release | 10–11 | Second beta: configuration fix, Grok Integration naming, translations, and optional Grok Documents Collections support. | Aug 3, 2026 | |
| 1.0.0-beta1 | Pre-release | 10–11 | First beta with full xAI chat, image, video, voice, moderation, classification, and hosted-tool support. | Aug 2, 2026 | |
| 1.0.0-alpha9 | Pre-release | 10–11 | Renames the module machine name to grok and includes beta-readiness security and reliability fixes. | Aug 1, 2026 | |
| 1.0.0-alpha8 | Pre-release | 10–11 | Conditional AI Image Studio guidance, direct workspace linking, and packaged translations. | Jul 31, 2026 | |
| 1.0.0-alpha7 | Pre-release | 10–11 | Shared Torneo AI pricing integration and a Grok Chat Explorer seed compatibility fix. | Jul 28, 2026 | |
| 1.0.0-alpha6 | Pre-release | 10–11 | Administrator-controlled xAI pricing updates, safer cost configuration, and improved setup guidance. | Jul 28, 2026 | |
| 1.0.0-alpha5 | Pre-release | 10–11 | Configurable Explorer prompts and shared image sources with optional visual Media Library selection. | Jul 27, 2026 | |
| 1.0.0-alpha4 | Pre-release | 10–11 | grok-alpha4 | Jul 27, 2026 | |
| 1.0.0-alpha3 | Pre-release | 10–11 | Jul 26, 2026 | ||
| 1.x-dev | Dev | 10–11 | Jul 25, 2026 |