Package com.tnsai.llm.providers
Class XAIGrokClient
java.lang.Object
com.tnsai.llm.providers.AbstractLLMClient
com.tnsai.llm.providers.AbstractOpenAICompatibleClient
com.tnsai.llm.providers.XAIGrokClient
- All Implemented Interfaces:
com.tnsai.llm.LLMClient
xAI Grok LLM client.
xAI's API is OpenAI-compatible — the same chat-completions wire
format as GroqClient / OpenRouterClient /
NvidiaNIMClient. This client targets the cloud endpoint at
https://api.x.ai/v1 by default; a baseUrl parameter or
the XAI_BASE_URL env var swaps it for a mirror or proxy.
Supported models (at time of writing):
- grok-3 — flagship Grok 3 (general chat + tool use)
- grok-3-mini — smaller / cheaper Grok 3
- grok-2-vision — multimodal Grok 2 (image input)
- grok-beta — pre-release tier; availability gated by xAI
The catalog evolves quickly; check the live list at docs.x.ai/api.
Configuration via environment variables:
XAI_API_KEY— Required for the cloud endpoint.XAI_BASE_URL— Optional override, defaults tohttps://api.x.ai/v1.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionXAIGrokClient(String model) XAIGrokClient(String model, float temperature) XAIGrokClient(String model, float temperature, Float topP, Integer maxTokens) XAIGrokClient(String model, float temperature, Integer maxTokens) XAIGrokClient(String baseUrl, String model, float temperature, Float topP, Integer maxTokens, String apiKey) XAIGrokClient(String baseUrl, String model, float temperature, Integer maxTokens, String apiKey) -
Method Summary
Methods inherited from class com.tnsai.llm.providers.AbstractOpenAICompatibleClient
chat, streamChatMethods inherited from class com.tnsai.llm.providers.AbstractLLMClient
getBaseUrl, getCallTimeoutMs, getMaxTokens, getModel, getTemperature, getTopPMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.tnsai.llm.LLMClient
chat, chat, chat, chat, chat, getCapabilities, getProviderName, listModels, streamChat, streamChat, streamChatWithHandler, streamChatWithHandler, streamChatWithSpec, streamChatWithSpec
-
Constructor Details
-
XAIGrokClient
-
XAIGrokClient
-
XAIGrokClient
-
XAIGrokClient
-
XAIGrokClient
-
XAIGrokClient
-