xAI: API key and base URL

Grok models, official API. Bring your own key; nothing is billed by us.

What the harness already knows

Provider idxai
Base URLhttps://api.x.ai/v1
ProtocolOpenAI-compatible chat completions
API keyXAI_API_KEY
Model discoveryYes — the model list is asked of the endpoint rather than shipped.

Connecting it

The endpoint above is built in, so there is nothing to configure. Put the key in the environment and the provider appears in the model picker:

export XAI_API_KEY="..."

Keys are issued by xAI — where to get one.

Models on xAI

The newest models xAI serves that can call tools, from the models.dev snapshot OHarness ships. The harness also asks the endpoint for its live list, so a model released after this snapshot still appears in the picker.

Model idContext / output$/M in / cached / outReasoning
grok-4.6500K / 500K2 / 0.5 / 6Yes
grok-4.5500K / 500K2 / 0.3 / 6Yes
grok-4.31M / 30K1.25 / 0.2 / 2.5Yes
grok-build-0.1256K / 256K1 / 0.2 / 2Yes
grok-4.20-0309-non-reasoning1M / 30K1.25 / 0.2 / 2.5No
grok-4.20-0309-reasoning1M / 30K1.25 / 0.2 / 2.5Yes

List prices in USD per million tokens, read from models.dev on 2026-09-19. xAI changes its prices and models; its own pricing page is the authority. Start a session on the newest:

oharness -m xai/grok-4.6

Pointing it somewhere else

A regional host, a gateway, or a server of your own. Overrides in ~/.oharness/config.json are field level, so changing the endpoint does not mean restating the rest of the provider — this is the whole block, shown holding the default so the shape is clear:

{
  "providers": {
    "xai": {
      "baseUrl": "https://api.x.ai/v1"
    }
  }
}

What you get either way

The same agent loop, the same tools, the same MCP servers and the same permission rules, whichever provider is underneath — and switching between them mid-session converts nothing, because history is never stored in a vendor’s shape. What an agent harness is covers why that is the hard part, and the providers reference covers the catalogue itself.

All 34 providers · Install OHarness