> ## 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 | 1M      |
| `grok-4.20-0309-reasoning`     | chat | 1M      |
| `grok-4.20-multi-agent-0309`   | chat | 1M      |
| `grok-4.3`                     | chat | 1M      |
| `grok-4.5`                     | 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](/provider-compatibility/models#live-registry) for pricing, benchmarks, and deprecation dates.
</Note>

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](/platform/gates) and grab an [API key](/getting-started/authentication) — the examples below need a `GATE_ID` and `VERLON_API_KEY`.
</Note>

The fastest path — Verlon SDK, one call:

```typescript theme={null}
import { Verlon } from '@verlon-ai/sdk';

const verlon = new Verlon({ apiKey: process.env.VERLON_API_KEY });

const response = await verlon.chat({
  gateId: process.env.GATE_ID,
  model: 'grok-4.5', // optional — overrides the gate's configured model
  data: {
    messages: [{ role: 'user', content: 'Hello!' }],
  },
});

console.log(response.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 `reasoningEffort`:

```typescript theme={null}
const response = await verlon.chat({
  gateId: process.env.GATE_ID,
  data: {
    messages: [{ role: 'user', content: 'Prove there are infinitely many primes.' }],
    reasoningEffort: '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 `maxTokens` for reasoning models — so a small `maxTokens` won't get consumed entirely by thinking, leaving no room for the answer.

`reasoningEffort` is portable: the same value maps to `reasoning_effort` on OpenAI, a thinking-token budget on Anthropic and Google, and is ignored by Mistral. Switching models doesn't require changing your code.

## SDK compatibility

The [Verlon SDK](/sdk-reference/overview) is the native path to every model on this page — the [quickstart above](#quickstart) is all it takes. Already on another SDK? Any SDK with a Verlon drop-in endpoint can reach these models too — today that's the [OpenAI SDK](/provider-compatibility/openai) and the [Anthropic SDK](/provider-compatibility/anthropic): point it at Verlon, reference a gate that routes here, and your code stays unchanged.

### Streaming

```typescript theme={null}
for await (const chunk of verlon.chatStream({
  gateId: process.env.GATE_ID,
  data: { messages: [{ role: 'user', content: 'Tell me a joke.' }] },
})) {
  process.stdout.write(chunk.content ?? '');
}
```

## What's supported

<AccordionGroup>
  <Accordion title="Streaming">
    Full support for `stream: true` in every supported SDK — identical semantics to the source SDK.
  </Accordion>

  <Accordion title="Tool / function calling">
    Fully supported. Verlon translates the tool-call shape between OpenAI / Anthropic / xAI native formats.
  </Accordion>

  <Accordion title="Vision">
    Every Grok chat model accepts image input alongside text. Max 20MiB per image, JPEG or PNG, no limit on image count.
  </Accordion>

  <Accordion title="Structured output">
    `responseFormat` with `json_object` or a `json_schema` works the same as on OpenAI.
  </Accordion>

  <Accordion title="Reasoning effort">
    `reasoningEffort` maps to xAI's `reasoning.effort`. See [Reasoning](#reasoning) above.
  </Accordion>

  <Accordion title="Standard parameters">
    `temperature`, `maxTokens`, `topP`, and `stop` are passed through. Note that `frequencyPenalty` and `presencePenalty` are rejected outright by Grok's reasoning models — Verlon strips them for you rather than letting the request fail.
  </Accordion>

  <Accordion title="Image + video generation">
    Grok Imagine models are available through `verlon.image()` and `verlon.video()`. See [Other modalities](#other-modalities).
  </Accordion>

  <Accordion title="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).
  </Accordion>
</AccordionGroup>

### 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** — 2 models
* **video** — 2 models

```typescript theme={null}
const image = await verlon.image({
  gateId: process.env.GATE_ID,
  model: 'grok-imagine-image',
  data: { prompt: 'A single red maple leaf on white', count: 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.

## 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 Verlon SDK it surfaces as a thrown `Error`:

```typescript theme={null}
try {
  await verlon.chat({
    gateId: process.env.GATE_ID,
    data: { messages: [{ role: 'user', content: 'Hello!' }] },
  });
} catch (error) {
  // error.message carries the API's message,
  // e.g. 'Gate with ID "…" not found'
  console.error(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

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

### Video

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

## Related

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