# `Alloy.Provider.XAI`
[🔗](https://github.com/alloy-ex/alloy/blob/v0.10.1/lib/alloy/provider/xai.ex#L1)

Provider for xAI's Grok models.

Thin wrapper around `Alloy.Provider.OpenAI` that sets xAI defaults.
xAI implements the OpenAI Responses API at `https://api.x.ai`.

## Config

Required:
- `:api_key` - xAI API key
- `:model` - Model name (e.g., "grok-4", "grok-4.1-fast-reasoning", "grok-code-fast-1")

Optional:
- `:web_search` - `true` or config map to enable Grok's web search tool
- `:x_search` - `true` or config map to enable search across X posts
- All options from `Alloy.Provider.OpenAI` (`:max_tokens`, `:tool_choice`, etc.)

## Example

    Alloy.run("What's happening on X today?",
      provider: {Alloy.Provider.XAI,
        api_key: System.get_env("XAI_API_KEY"),
        model: "grok-4",
        web_search: true
      }
    )

## With X search

    Alloy.run("What are people saying about Elixir agents?",
      provider: {Alloy.Provider.XAI,
        api_key: System.get_env("XAI_API_KEY"),
        model: "grok-4",
        x_search: true
      }
    )

---

*Consult [api-reference.md](api-reference.md) for complete listing*
