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

# xAI

> xAI builds the Grok model family with real-time knowledge access (trained on X/Twitter data) and strong reasoning capabilities.

xAI offers 24 models through Lava's AI Gateway, supporting Chat Completions, Chat Completions (Native). Authentication uses `Authorization: Bearer`. See the [xAI API docs](https://docs.x.ai/api) for provider-specific parameters.

> [!NOTE]
>
> Supports both **managed** (Lava's API keys) and **unmanaged** (bring your own credentials) mode.

## Quick Start

```typescript theme={null}
const response = await fetch('https://api.lava.so/v1/forward?u=https%3A%2F%2Fapi.x.ai%2Fv1%2Fchat%2Fcompletions', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    Authorization: `Bearer ${forwardToken}`,
  },
  body: JSON.stringify({
    model: 'grok-4.7',
    messages: [{ role: "user", content: "Hello!" }],
  }),
});
```

## Chat Completions

**Target URL:** `https://api.x.ai/v1/chat/completions`

| | |
| - | - |
| **Content Type** | `application/json` |
| **Streaming** | Yes (set `stream: true` in request body) |

| Model | Input / 1M tokens | Output / 1M tokens |
| - | - | - |
| grok-4.7 | \$2.00 | \$6.00 |
| grok-4.6 | \$2.00 | \$6.00 |
| grok-4.5 | \$2.00 | \$6.00 |
| grok-4.5-latest | \$2.00 | \$6.00 |
| grok-build-latest | \$2.00 | \$6.00 |
| grok-4.20-0309-reasoning | \$2.00 | \$6.00 |
| grok-4.20-0309-non-reasoning | \$2.00 | \$6.00 |
| grok-4.20-multi-agent-0309 | \$2.00 | \$6.00 |
| grok-4.3 | \$1.25 | \$2.50 |
| grok-4.3-latest | \$1.25 | \$2.50 |
| grok-latest | \$1.25 | \$2.50 |
| grok-build-0.1 | \$1.00 | \$2.00 |

## Chat Completions (Native)

**Target URL:** `https://api.x.ai/v1/messages`

| | |
| - | - |
| **Content Type** | `application/json` |
| **Streaming** | Yes (set `stream: true` in request body) |

| Model | Input / 1M tokens | Output / 1M tokens |
| - | - | - |
| grok-4.7 | \$2.00 | \$6.00 |
| grok-4.6 | \$2.00 | \$6.00 |
| grok-4.5 | \$2.00 | \$6.00 |
| grok-4.5-latest | \$2.00 | \$6.00 |
| grok-build-latest | \$2.00 | \$6.00 |
| grok-4.20-0309-reasoning | \$2.00 | \$6.00 |
| grok-4.20-0309-non-reasoning | \$2.00 | \$6.00 |
| grok-4.20-multi-agent-0309 | \$2.00 | \$6.00 |
| grok-4.3 | \$1.25 | \$2.50 |
| grok-4.3-latest | \$1.25 | \$2.50 |
| grok-latest | \$1.25 | \$2.50 |
| grok-build-0.1 | \$1.00 | \$2.00 |

## Next Steps

> [card] [All Providers](https://lava.so/docs/gateway/supported-providers.md)
>
> Browse all supported AI providers

> [card] [Forward Proxy](https://lava.so/docs/gateway/forward-proxy.md)
>
> Learn how to construct proxy URLs and authenticate requests


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