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

# xAI (Grok)

# xAI (Grok)

xAI provides the Grok model family through an OpenAI-compatible API. WednesdayAI integrates with xAI for text and vision inference. The default model is `grok-4`.

## Requirements

* An xAI API key from [console.x.ai](https://console.x.ai)

## Quickstart

```bash theme={"dark"}
wednesdayai onboard --auth-choice xai-api-key
```

Or non-interactive:

```bash theme={"dark"}
wednesdayai onboard --non-interactive \
  --mode local \
  --auth-choice xai-api-key \
  --xai-api-key "$XAI_API_KEY"
```

Then verify the default model was set:

```bash theme={"dark"}
wednesdayai models status
```

## Configuration

### Environment variable

```bash theme={"dark"}
export XAI_API_KEY="xai-..."
```

WednesdayAI reads `XAI_API_KEY` automatically and enables the `xai` provider.

### Config snippet

```json5 theme={"dark"}
{
  env: { XAI_API_KEY: "xai-..." },
  agents: {
    defaults: {
      model: { primary: "xai/grok-4" },
    },
  },
}
```

### Provider settings

| Setting | Value |
| - | - |
| Provider ID | `xai` |
| Base URL | `https://api.x.ai/v1` |
| API | OpenAI-compatible (`openai-completions`) |
| Auth env var | `XAI_API_KEY` |
| Default model | `grok-4` |
| Default context window | 256,000 tokens |
| Default max tokens | 8,192 |

## Available models

| Model ID | Name | Context | Notes |
| - | - | - | - |
| `grok-4` | Grok 4 | 256K | Default; reasoning |
| `grok-code-fast-1` | Grok Code Fast 1 | 256K | Reasoning; coding |
| `grok-4-fast` | Grok 4 Fast | 2M | Reasoning; vision |
| `grok-4-fast-non-reasoning` | Grok 4 Fast (non-reasoning) | 2M | Vision |
| `grok-4-1-fast` | Grok 4.1 Fast | 2M | Reasoning; vision |
| `grok-4-1-fast-non-reasoning` | Grok 4.1 Fast (non-reasoning) | 2M | Vision |
| `grok-3` | Grok 3 | 131K | |
| `grok-3-latest` | Grok 3 Latest | 131K | |
| `grok-3-fast` | Grok 3 Fast | 131K | |
| `grok-3-fast-latest` | Grok 3 Fast Latest | 131K | |
| `grok-3-mini` | Grok 3 Mini | 131K | Reasoning |
| `grok-3-mini-latest` | Grok 3 Mini Latest | 131K | Reasoning |
| `grok-3-mini-fast` | Grok 3 Mini Fast | 131K | Reasoning |
| `grok-3-mini-fast-latest` | Grok 3 Mini Fast Latest | 131K | Reasoning |
| `grok-2` | Grok 2 | 131K | |
| `grok-2-latest` | Grok 2 Latest | 131K | |
| `grok-2-vision` | Grok 2 Vision | 8K | Vision |
| `grok-2-vision-latest` | Grok 2 Vision Latest | 8K | Vision |

Use model IDs as `xai/<model-id>` (example: `xai/grok-4`).

## Web search with Grok

xAI's Grok supports live web search via the Responses API. You can configure it separately for the web search tool:

```json5 theme={"dark"}
{
  tools: {
    web: {
      search: {
        grok: {
          apiKey: "xai-...", // falls back to XAI_API_KEY
        },
      },
    },
  },
}
```

The web search tool uses `grok-4-1-fast` by default when Grok search is enabled. See [Tools: web search](https://docs.wednesdayai.dev/next/users/tools/web.md) for full configuration.

## Troubleshooting

**401 Unauthorized**

* Verify your key starts with `xai-` and is copied in full.
* Re-run onboarding: `wednesdayai onboard --auth-choice xai-api-key`.

**Tool schema errors**

xAI rejects certain JSON Schema keywords in tool definitions. WednesdayAI automatically sanitizes tool schemas for xAI — no configuration needed.

**Model not found**

* Confirm the model ID is correct and your xAI plan includes it.
* Run `wednesdayai models status` to see detected xAI models.

## Related

* [Model providers](https://docs.wednesdayai.dev/next/developers/concepts/model-providers.md)
* [Models](https://docs.wednesdayai.dev/next/developers/concepts/models.md)
* [Model failover](https://docs.wednesdayai.dev/next/developers/concepts/model-failover.md)
* [Gateway configuration](https://docs.wednesdayai.dev/next/admin/gateway/configuration.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.