The xAI API that serves Grok models is billed per token, not by subscription: you pay for the volume you actually send, and the key is issued in the console at docs.x.ai. Model prices differ severalfold, from $1 per million input tokens for the lightweight grok-build-0.1 to $2 for the flagships. For someone in Russia, though, the hard part is not the API itself but paying for it. xAI takes international cards, and cards from Russian banks do not go through.
Grok models in the API and per-token prices
According to docs.x.ai, these models are available in the API as of September 2026:
| Model | Context | Input, $/1M | Output, $/1M |
|---|---|---|---|
| grok-4.7 | 500K | $2.00 | $6.00 |
| grok-4.6 | 500K | $2.00 | $6.00 |
| grok-4.5 | 500K | $2.00 | $6.00 |
| grok-4.3 | 1M | $1.25 | $2.50 |
| grok-4.20-0309-reasoning | 1M | $1.25 | $2.50 |
| grok-4.20-0309-non-reasoning | 1M | $1.25 | $2.50 |
| grok-4.20-multi-agent-0309 | 1M | $1.25 | $2.50 |
| grok-build-0.1 | 256K | $1.00 | $2.00 |
Source: docs.x.ai/developers/pricing. The prices are current as of writing (September 2026) and may change later.
One billing detail is easy to miss. If a prompt is longer than 200 thousand tokens, the whole request is charged at the higher rate, not just the part above the threshold. For grok-4.7 that means a jump from $2/$6 to $4/$12 per million input and output tokens. Budget for long context at the upper rate up front, not after the first invoice.
According to the official model documentation, Grok 4.7 is xAI's flagship as of September 2026: a 500 thousand token context window, text and images in, text out. Reasoning levels are configurable: low, medium, high (the default) and xhigh. The knowledge cutoff is May 2026. The newer releases in the line, 4.7 and 4.6 among them, are covered in Grok 4.7 and 4.6: what's new.
The API's companion services are priced separately: a voice agent at $0.08 per minute, speech synthesis at $15 per million characters, and speech recognition at $0.10 per hour in batch mode and $0.20 per hour when streaming. These figures also come from the pricing page, as of September 2026.
How to get an xAI API key
You create the key in the console at docs.x.ai after registering an account. The flow is the same as for most LLM APIs: sign in, open the API keys section, generate a key and put it in the request header. Check the exact sequence of screens on docs.x.ai itself when you register, because AI providers' consoles change faster than overviews get written.
OpenAI compatibility in practice
The xAI API follows the OpenAI Chat Completions format. In theory, code written for the OpenAI SDK moves to Grok by swapping the base URL and the model id, with no changes to the request structure. In practice compatibility is rarely complete. The reasoning-level parameters (low, medium, high, xhigh) exist only in Grok and have no direct counterpart in the OpenAI API, so some of your code will still need adjusting for the specific model.
Many gateways and providers use the same OpenAI-compatible endpoint approach, codexkey included: setting up a tool comes down to changing the base URL, the key and the model id, while the request format stays familiar.
Paying from Russia: where it breaks and what to do
xAI offers no direct way to pay with a Russian bank card. The cause is not the API but the payment processor: it checks the card's BIN code and rejects Russian banks whether a VPN is on or not. Mir cards have not been accepted by foreign acquiring since March 2022, a general consequence of sanctions that has nothing specific to do with xAI.
If you used the Grok API for code, text or agent work rather than for something unique to the xAI line such as Grok Imagine, codexkey has an API that works much the same way and takes payment that goes through from Russia:
import anthropic
client = anthropic.Anthropic(
api_key="sk_cdx_YOUR_KEY",
base_url="https://api.codexkey.online",
)
message = client.messages.create(
model="claude-opus-5",
max_tokens=1024,
messages=[{"role": "user", "content": "Review this code and find the bug"}],
)
A key like sk_cdx_... is created in your account, you can pay with a Russian card or through SBP (the Russian Faster Payments System), and top-ups start from 1 dollar. Claude Opus 5 and Claude Sonnet 5 cost $0.3 per million tokens for both input and output. That is cheaper than the Grok flagships, although price is not the only criterion for choosing a model. The cost breakdown and the list of models are on the Pricing and Models pages, and the first request is walked through in the Quickstart.
If you are comparing gateways that reach several providers at once, not just Claude, read codexkey vs OpenRouter: it shows where a multi-model aggregator wins and where it does not.
FAQ
How much does the Grok API cost?
It depends on the model. An input token costs from $1 per million on the lightweight grok-build-0.1 to $2 on the Grok 4.7, 4.6 and 4.5 flagships, and the rate rises to $4 when the prompt is longer than 200 thousand tokens. The current table is at docs.x.ai/developers/pricing.
Which Grok models are available in the API right now?
As of September 2026: Grok 4.7, 4.6, 4.5, 4.3, three Grok 4.20 variants (reasoning, non-reasoning, multi-agent) and grok-build-0.1 for agentic work in the terminal.
Can I use the OpenAI SDK with the Grok API?
Yes, the xAI API follows the OpenAI Chat Completions format, but not completely: parameters that exist only in Grok, such as the reasoning levels, need separate setup for each model.
Why can't I pay for the Grok API with a Russian bank card?
xAI's payment processor rejects cards with Russian BIN codes, and a VPN does not change that. Mir cards have not worked abroad since 2022 because of sanctions.
What can replace the Grok API if payment from Russia fails?
For code, text analysis and agent workflows, the codexkey API fits: Claude models and payment by Russian card or SBP. For products that exist only at xAI, Grok Imagine for example, codexkey has no counterpart.
What is grok-build-0.1?
A separate API model for agentic work in the terminal, part of the Grok Build product. It has a 256 thousand token context and costs $1 per million input and $2 per million output tokens, the cheapest in the current Grok line.