← All guides

How to use Grok in Claude Code

xAI's Grok models — including the fast, cheap coding-focused ones — are a tempting option for agent coding. Claude Code can be pointed at Grok, though it takes an extra step. Here's how, what to watch for, and a cleaner path.

TL;DR: Grok's API from xAI is OpenAI-compatible, not Anthropic-shaped, so Claude Code needs a small translating proxy in front (set ANTHROPIC_BASE_URL to the proxy, ANTHROPIC_AUTH_TOKEN to your xAI key, pick a Grok model). It works and Grok's coding-tuned models are fast and cheap, but the proxy is one more moving part and it's still a global switch. An agent that speaks OpenAI-compatible endpoints natively skips the proxy entirely.

Grok + Claude Code: the catch

Grok is served by xAI over an OpenAI-compatible API. Claude Code expects the Anthropic Messages API shape, so unlike DeepSeek/Kimi/Qwen (which offer Anthropic-compatible endpoints), Grok usually needs a small proxy that translates between the two. Once that translator is in place, Claude Code can drive Grok like any other endpoint.

The config

What to set

  1. A translating proxyRun a small proxy that accepts Anthropic-shaped requests and forwards them to xAI's OpenAI-compatible Grok API.
  2. ANTHROPIC_BASE_URLPoint Claude Code at your local proxy, not directly at xAI.
  3. ANTHROPIC_AUTH_TOKENYour xAI API key (or whatever the proxy expects), billed to your xAI account.
  4. ModelSelect a Grok model — the coding-tuned 'code fast' style models are the usual pick for agent work.
Reality check: the proxy is an extra service to run and keep updated, and tool-calling behavior varies by model, so test Grok on a real agent task first. It's also still one global endpoint — switching back to Claude means reconfiguring.

Why people want Grok for coding

What Grok brings

ReasonDetail
SpeedxAI's coding-tuned models are built for fast responses
CostCompetitive per-token pricing for routine coding
Another fallbackOne more provider to switch to when others are capped

The cleaner option: skip the proxy

Because Grok is OpenAI-compatible, the friction is entirely Claude Code's Anthropic-only assumption. An agent that speaks OpenAI-compatible endpoints natively doesn't need a translating proxy at all — you add Grok as a provider with its base URL and key, and it just works. That removes the extra service and the restart-to-switch dance.

What that looks like with Wuwei

No proxy

OpenAI-compatible providers like xAI/Grok connect directly — no Anthropic-shape translator to run.

Grok in the model list

Pick it next to Claude, DeepSeek, Kimi, Qwen and GLM; switch in a click.

Free, open source, local

MIT-licensed, runs on your machine, reads your real files; you only pay xAI's usage.

FAQ

Can Claude Code use Grok?

Yes, with an extra step. Grok's xAI API is OpenAI-compatible, so Claude Code needs a small translating proxy in front (point ANTHROPIC_BASE_URL at the proxy, use your xAI key, pick a Grok model). Agents that speak OpenAI-compatible endpoints natively skip the proxy.

Is Grok good for coding?

xAI's coding-tuned Grok models are fast and cost-competitive, which makes them a reasonable pick for routine agent coding. As always, test tool-calling on a real task before relying on it for heavy loops.

How do I use Grok without running a proxy?

Use an agent that supports OpenAI-compatible providers directly. Wuwei is free and open source — add Grok with its base URL and key, no translating proxy, and switch to Claude or other models in a click.

If you want to code with xAI's fast Grok models without maintaining a translating proxy, Wuwei connects OpenAI-compatible providers directly and puts Grok in the same one-click model list as Claude — free, open source, running locally on your real files.

Windows · macOS · Linux — free, no login