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

# xAI

> Every xAI model Verlon supports — Grok 4.5, Grok 4.3, the Grok 4.20 line, Grok Build, and Grok Imagine — with quickstart, long-context pricing, and SDK compatibility.

xAI's Grok lineup — Grok 4.5 (flagship reasoning), Grok 4.3 and the Grok 4.20 line (1M context), Grok Build (code, also known as `grok-code-fast-1`), and Grok Imagine (image and video) — is routable through Verlon in whichever SDK you already use. No xAI-specific SDK required.

## Chat models

| Model ID | Type | Context |
| - | - | - |
| `grok-4.20-0309-non-reasoning` | chat | 1000K |
| `grok-4.20-0309-reasoning` | chat | 1000K |
| `grok-4.20-multi-agent-0309` | chat | 1000K |
| `grok-4.3` | chat | 1000K |
| `grok-4.5` | chat | 500K |
| `grok-4.6` | chat | 500K |
| `grok-4.7` | chat | 500K |
| `grok-build-0.1` | chat | 256K |

> [!NOTE]
>
> This table is auto-generated from the Verlon model registry on every sync —
> see the [live registry](https://docs.verlon.ai/provider-compatibility/models.md#live-registry) for
> pricing, benchmarks, and deprecation dates.

xAI also publishes aliases that track the newest release of a line — `grok-4.5-latest`, `grok-latest`, `grok-code-fast-1`. Those resolve on xAI's side, so you can use them here too; pin a dated ID when you need version stability.

## Long-context pricing

Grok is the first provider on Verlon that **re-prices an entire request** once its prompt gets large. Every current Grok text model doubles its rates — input, cached input, and output alike — when the prompt reaches **200,000 tokens**:

| Model | Standard (\< 200K prompt) | Long context (≥ 200K prompt) |
| - | - | - |
| `grok-4.5` | $2.00 in · $0.30 cached · \$6.00 out | $4.00 in · $0.60 cached · \$12.00 out |
| `grok-4.3`, `grok-4.20-*` | $1.25 in · $0.20 cached · \$2.50 out | $2.50 in · $0.40 cached · \$5.00 out |
| `grok-build-0.1` | $1.00 in · $0.20 cached · \$2.00 out | $2.00 in · $0.40 cached · \$4.00 out |

Three things worth knowing:

* **The trigger is prompt size only.** A long *response* never moves you into the higher tier.
* **It applies to the whole request**, not just the tokens past the threshold. A 201K-token prompt bills every one of those tokens at the doubled rate.
* **Verlon bills this correctly for you.** The `cost` field on every response already reflects whichever tier applied, so you don't need to compute it yourself.

If you're near the boundary and cost-sensitive, trimming a prompt from 205K to 195K tokens roughly halves the bill for that call.

## Quickstart

> [!NOTE]
>
> First time? [Create a gate](https://docs.verlon.ai/platform/gates.md) and grab an [API
> key](https://docs.verlon.ai/getting-started/authentication.md) — the examples below need a `GATE_ID`
> and `VERLON_API_KEY`.

The fastest path — the official OpenAI SDK, pointed at Verlon:

```typescript theme={null}
import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: 'https://api.verlon.ai/v1',
  apiKey: process.env.VERLON_API_KEY,
});

// @ts-ignore - gateId is a Verlon AI extension
const response = await openai.chat.completions.create({
  gateId: process.env.GATE_ID,
  model: 'grok-4.5', // optional — overrides the gate's configured model
  messages: [{ role: 'user', content: 'Hello!' }],
});

console.log(response.choices[0].message.content);
```

Any chat model from the table above works — swap `grok-4.5` for `grok-4.3`, `grok-build-0.1`, or any other ID.

## Reasoning

Grok reasons by default and **reasoning cannot be turned off**. You can control how much of it happens with `reasoning_effort`:

```typescript theme={null}
const response = await openai.chat.completions.create({
  gateId: process.env.GATE_ID,
  messages: [
    { role: 'user', content: 'Prove there are infinitely many primes.' },
  ],
  reasoning_effort: 'high', // 'low' | 'medium' | 'high' — xAI defaults to 'high'
});
```

Because reasoning tokens are billed as output and count against your output cap, Verlon automatically reserves extra headroom on top of your `max_tokens` for reasoning models — so a small `max_tokens` won't get consumed entirely by thinking, leaving no room for the answer.

`reasoning_effort` is portable: Verlon passes the same value straight through to OpenAI, maps it to a thinking-token budget on Anthropic and Google, and ignores it for Mistral. Switching models doesn't require changing your code.

## SDK compatibility

Any SDK with a Verlon drop-in endpoint can reach every model on this page — today that's the [OpenAI SDK](https://docs.verlon.ai/provider-compatibility/openai.md) and the [Anthropic SDK](https://docs.verlon.ai/provider-compatibility/anthropic.md): point it at Verlon, reference a gate that routes here, and your code stays unchanged. The [quickstart above](#quickstart) is all it takes. The [Verlon SDK](https://docs.verlon.ai/sdk-reference/overview.md) isn't needed for inference — its home is agent tracing, observability, and the model registry.

### Streaming

```typescript theme={null}
const stream = await openai.chat.completions.create({
  gateId: process.env.GATE_ID,
  messages: [{ role: 'user', content: 'Tell me a joke.' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}
```

## What's supported

> [accordion] Streaming
>
> Full support for `stream: true` in every supported SDK — identical semantics
> to the source SDK.

> [accordion] Tool / function calling
>
> Fully supported. Verlon translates the tool-call shape between OpenAI /
> Anthropic / xAI native formats.

> [accordion] Vision
>
> Every Grok chat model accepts image input alongside text. Max 20MiB per
> image, JPEG or PNG, no limit on image count.

> [accordion] Structured output
>
> `response_format` with `json_object` or a `json_schema` works the same as on
> OpenAI.

> [accordion] Reasoning effort
>
> `reasoning_effort` maps to xAI's `reasoning.effort`. See
> [Reasoning](#reasoning) above.

> [accordion] Standard parameters
>
> `temperature`, `max_tokens`, `top_p`, and `stop` are passed through. Note
> that `frequency_penalty` and `presence_penalty` are rejected outright by
> Grok's reasoning models — Verlon strips them for you rather than letting the
> request fail.

> [accordion] Image + video generation
>
> Grok Imagine image models are available through the drop-in
> `/v1/images/generations` route. Video generation is served through the
> drop-in `/v1/videos` async surface (`openai.videos.create()` → poll →
> download). See [Other modalities](#other-modalities).

> [accordion] Usage + cost tracking
>
> Every response includes token usage plus Verlon's `cost` field with per-call
> dollar amount, already reflecting the correct [pricing
> tier](#long-context-pricing).

### Not available

* **Embeddings.** xAI publishes no embeddings model. Use OpenAI, Google, or Mistral embeddings and route your chat traffic to Grok — that mix is exactly what gates are for.
* **Text-to-speech.** xAI's voice models are realtime/websocket-only and aren't reachable through the standard TTS surface.
* **OCR.** No xAI equivalent; Mistral's OCR line is the recommended path.

## Other modalities

* **image generation** — 3 models
* **video generation** — 3 models

```typescript theme={null}
const image = await openai.images.generate({
  gateId: process.env.GATE_ID,
  model: 'grok-imagine-image',
  prompt: 'A single red maple leaf on white',
  n: 1,
});
```

Image generation is billed per image ($0.02 for `grok-imagine-image`, $0.05 for `grok-imagine-image-quality`); video is billed per second of output. Video generation runs through the drop-in `/v1/videos` async surface — create a job with `openai.videos.create()`, poll it, download the result.

## How it works

1. **You send** a request in your chosen SDK's format
2. **Verlon receives** — validates the gate, applies routing rules
3. **Verlon translates** to xAI's format and dispatches to xAI's API
4. **xAI responds** with its raw response
5. **Verlon normalizes** back to your SDK's expected shape
6. **You receive** a response in the format your code already handles, with an added `cost` field

Your existing code doesn't know it's talking to xAI.

## Errors

| Status | Meaning | What to check |
| - | - | - |
| `400` | Invalid request | Malformed body or missing `gateId` |
| `401` | Invalid API key | Your `VERLON_API_KEY` value and the `Authorization: Bearer` header |
| `404` | Gate not found | Your `GATE_ID` — the error message names the offending ID |
| `429` | Rate limit exceeded | Back off and retry; the body includes `reset_at`, and every response carries `X-RateLimit-*` headers |

The error shape always matches the SDK you're calling with. Through the OpenAI SDK it surfaces as a thrown `APIError`:

```typescript theme={null}
try {
  await openai.chat.completions.create({
    gateId: process.env.GATE_ID,
    messages: [{ role: 'user', content: 'Hello!' }],
  });
} catch (error) {
  // error.status and error.message carry the API's answer,
  // e.g. 404 'Gate with ID "…" not found'
  console.error(error.status, error.message);
}
```

## Full non-chat model list

Every non-chat xAI model Verlon routes to, grouped by modality. Chat models are in the table near the top of this page.

### Image generation

| Model ID |
| - |
| `grok-imagine-image` |
| `grok-imagine-image-2.0` |
| `grok-imagine-image-quality` |

### Video generation

| Model ID |
| - |
| `grok-imagine-video` |
| `grok-imagine-video-1.5` |
| `grok-imagine-video-1.5-lite` |

## Related

* [OpenAI](https://docs.verlon.ai/provider-compatibility/openai.md) · [Anthropic](https://docs.verlon.ai/provider-compatibility/anthropic.md) · [Google](https://docs.verlon.ai/provider-compatibility/google.md) · [Mistral](https://docs.verlon.ai/provider-compatibility/mistral.md)
* [Verlon SDK reference](https://docs.verlon.ai/sdk-reference/overview.md) — agent tracing, observability, and the model registry
* [Gates](https://docs.verlon.ai/platform/gates.md) — set up routing rules and model configuration
* [Bring your own key](https://docs.verlon.ai/platform/byok.md) — use your own xAI account for provider costs
* [xAI's official docs ↗](https://docs.x.ai/)


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