xAI (Grok)
The xAI plugin provides access to Grok models.
Installation
Section titled “Installation”<dependency> <groupId>com.google.genkit</groupId> <artifactId>genkit-plugin-xai</artifactId> <version>1.0.0-SNAPSHOT</version></dependency>Configuration
Section titled “Configuration”export XAI_API_KEY=your-api-keyimport com.google.genkit.plugins.xai.XAIPlugin;
Genkit genkit = Genkit.builder() .plugin(XAIPlugin.create()) .build();
ModelResponse response = genkit.generate( GenerateOptions.builder() .model("xai/grok-3") .prompt("Tell me about AI") .build());Available models
Section titled “Available models”| Model | Context Window |
|---|---|
xai/grok-4 | Up to 2M tokens |
xai/grok-4-1-fast | 131K tokens |
xai/grok-3 | 131K tokens |
xai/grok-3-mini | 131K tokens |
Features
Section titled “Features”- Text generation, streaming, tool calling, RAG
Sample
Section titled “Sample”See the xai sample.