LiteLLMModels

Grok Code Fast API Pricing

As of October 10, 2026, Grok Code Fast costs $1.00 per 1M input tokens and $2.00 per 1M output tokens on xAI, with cache reads at $0.20 per 1M tokens. It has a 256,000-token context window and returns up to 256,000 tokens per response.

By xAIModel ID xai/grok-code-fastPrices updated Checked
Input
$1.00 / 1M tokens
Output
$2.00 / 1M tokens
Cache read
$0.20 / 1M tokens
Context window
256,000 tokens
Max output
256,000 tokens
Providers
1
Added to LiteLLM
September 2025

Grok Code Fast pricing by provider

1 listing across 1 provider. Token prices are in US dollars per 1M tokens. The highlighted row is the price quoted above.

ProviderModel name in LiteLLMInputOutputCache readContext
xAIxai/grok-code-fast$1.00$2.00$0.20256K

Other Grok Code Fast prices on xAI

Input above 200K tokens$2.00 per 1M tokens
Output above 200K tokens$4.00 per 1M tokens
Cache read above 200K tokens$0.40 per 1M tokens

What Grok Code Fast costs in practice

1,000 requests with 2,000 input and 500 output tokens each

xAI$3.00

100 long-document requests with 100,000 input and 2,000 output tokens each

xAI$10.40

Grok Code Fast features

Use Grok Code Fast with LiteLLM

Call Grok Code Fast through the LiteLLM Python SDK, or put it behind the LiteLLM proxy and send OpenAI-format requests to /v1/chat/completions. LiteLLM tracks the cost of every request at these prices.

Python SDK
from litellm import completion

response = completion(
    model="xai/grok-code-fast",
    messages=[{"role": "user", "content": "Hello!"}],
)
Proxy config.yaml
model_list:
  - model_name: grok-code-fast
    litellm_params:
      model: xai/grok-code-fast
      api_key: os.environ/XAI_API_KEY
Call the proxy
curl http://0.0.0.0:4000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-1234" \
  -d '{
    "model": "grok-code-fast",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Grok Code Fast FAQ

How much does Grok Code Fast cost?

Grok Code Fast costs $1.00 per 1M input tokens and $2.00 per 1M output tokens on xAI, with cache reads at $0.20 per 1M tokens. Above 200K input tokens, input costs $2.00 and output costs $4.00 per 1M tokens.

What is the context window of Grok Code Fast?

Grok Code Fast has a 256,000-token context window and returns up to 256,000 tokens per response.

Which providers offer Grok Code Fast?

Grok Code Fast is available from xAI through LiteLLM, using the model name xai/grok-code-fast.

How do I call Grok Code Fast with an OpenAI-compatible API?

Use the LiteLLM Python SDK with model="xai/grok-code-fast", or add the model to the LiteLLM proxy's config.yaml and send requests to /v1/chat/completions from any OpenAI client. LiteLLM tracks the cost of every request at the prices on this page.

What features does Grok Code Fast support?

Grok Code Fast supports function calling, structured output, image input, reasoning and prompt caching.

When did LiteLLM add Grok Code Fast?

Grok Code Fast was added to LiteLLM's model price file in September 2025.

Sources

Prices come from LiteLLM's open-source model_prices_and_context_window.json, which LiteLLM uses to calculate the cost of every request. Provider pricing pages:

LiteLLM docs: xAI.

Provider pages: xAI.