Access Grok models with real-time web search and reasoning capabilities.
XAI_API_KEY=xai-...Passed via :provider_options keyword:
- Type: Integer
- Purpose: Preferred over
max_tokensfor Grok-4 models - Note: ReqLLM auto-translates
max_tokensfor models requiring it - Example:
provider_options: [max_completion_tokens: 2000]
- Type: Map
- Purpose: Enable Live Search with real-time web access
- Keys:
mode:"auto"(default),"always", or"never"max_sources: Maximum sources to cite (integer)date_range:"recent","week","month","year"citations: Include citations (boolean)
- Example:
provider_options: [ search_parameters: %{ mode: "auto", max_sources: 5, date_range: "recent", citations: true } ]
- Note: Live Search incurs additional costs per source
- Type: Boolean
- Default:
true - Purpose: Allow parallel function calls
- Example:
provider_options: [parallel_tool_calls: true]
- Type: Map
- Purpose: Configure streaming behavior
- Example:
provider_options: [stream_options: %{include_usage: true}]
- Type:
:auto|:json_schema|:tool_strict - Default:
:auto - Purpose: Control structured output strategy
:auto: Automatic selection based on model:json_schema: Native response_format (grok-2-1212+):tool_strict: Strict tool calling fallback- Example:
provider_options: [xai_structured_output_mode: :json_schema]
- Type: Map
- Purpose: Custom response format configuration
- Example:
provider_options: [ response_format: %{ type: "json_schema", json_schema: %{...} } ]
- Do NOT support
stop,presence_penalty, orfrequency_penalty - Use
max_completion_tokensinstead ofmax_tokens - Support native structured outputs
- Support
reasoning_effortparameter ("low","medium","high") - Efficient for cost-sensitive applications
- Support native structured outputs
- Vision support (grok-2-vision-1212)
xAI's native structured outputs have limitations (auto-sanitized by ReqLLM):
Not Supported:
minLength/maxLengthfor stringsminItems/maxItems/minContains/maxContainsfor arrayspatternconstraintsallOf(must be flattened)
Supported:
anyOfadditionalProperties: false(enforced on root)