> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anotherwrapper.com/llms.txt
> Use this file to discover all available pages before exploring further.

# xAI's Grok

> Set up Grok & understand how it's used throughout the app

xAI's Grok models bring strong reasoning capabilities to the table, including a fast reasoning mode that shows its chain of thought. If you want to give your users access to cutting-edge models from xAI, this is how to set it up.

## Get your API key

<Steps>
  <Step title="Create or sign into your xAI account">
    Head to the [xAI Console](https://console.x.ai/) and sign up or log in.
  </Step>

  <Step title="Generate an API key">
    Navigate to **API Keys** and click **Create new API key**.
  </Step>

  <Step title="Add it to your env">
    Paste the key in your `.env.local` file:

    ```env theme={null}
    XAI_API_KEY=your_xai_api_key
    ```
  </Step>
</Steps>

<Warning>
  Save your API key somewhere safe right away -- you won't be able to retrieve it later.
</Warning>

## Available models

All models are defined in the unified model registry at `lib/ai/models.ts`.

| Model                   | ID                        | Features           |
| ----------------------- | ------------------------- | ------------------ |
| Grok 4                  | `grok-4-latest`           | --                 |
| Grok 4.1                | `grok-4-1`                | --                 |
| Grok 4.1 Fast Reasoning | `grok-4-1-fast-reasoning` | Thinking/Reasoning |

<Tip>
  Grok 4.1 Fast Reasoning supports **thinking/reasoning mode** -- the model shows its chain of thought before giving you the final answer. It's great for complex analysis and problem-solving tasks.
</Tip>

## Apps using Grok

Grok is integrated through Vercel AI SDK 6.0, with provider routing handled by `lib/ai/ai-utils.ts`.

<CardGroup cols={2}>
  <Card title="Chat" icon="comments" href="/apps/chat">
    Multi-provider chat app -- Grok is available as an LLM provider
  </Card>

  <Card title="Marketing Plan" icon="chart-line" href="/apps/marketing-plan">
    Generate structured marketing plans using Grok models
  </Card>

  <Card title="Launch Simulator" icon="sparkles" href="/apps/launch-simulator">
    Generate Product Hunt launch simulations using Grok models
  </Card>
</CardGroup>

## How it works

The codebase uses Vercel AI SDK 6.0 with a unified model registry -- no direct xAI API calls needed.

Here's the typical flow for an AI request:

1. You select a model from the unified registry
2. The request goes through `getModelInstance()` in `lib/ai/ai-utils.ts`
3. The provider is determined via `getProviderFromModelId()`
4. The model is instantiated with `customModel()`
5. The response is streamed back to you
6. Results are stored in PostgreSQL

<Card title="Structure" icon="folder" href="/setup/structure">
  Understand the full project structure of the codebase.
</Card>
