cheapaimodelSearch
All posts

Grok API Pricing: Token Costs, Context Limits, and Worked Examples

By Nicho

Grok API pricing depends on the model, provider, request size, cached input, and any tools used. A headline price for text tokens is a starting point, not necessarily the full cost of an agent task.

This guide focuses on Grok 4.7, the Grok model listed on cheapaimodel when the prices below were checked on October 26, 2026. It compares published rates and calculated examples. It does not report measured quality, latency, or reliability tests, and it does not cover every Grok product.

Grok 4.7 token prices

Prices below are US dollars per million tokens. Cached and uncached input are separate categories.

Access route Uncached input / 1M Cached input / 1M Output / 1M
Official direct API, displayed base rates $2.00 $0.50 $6.00
cheapaimodel, displayed rates $0.198958 $0.049740 $0.596874

Sources: the official Grok 4.7 model page and cheapaimodel pricing. The direct model page also flags different pricing above 200K context. Its base table must not be applied automatically to larger requests or other processing modes.

The gateway prices shown here are lower than the displayed direct base rates for these three categories. That does not establish the cheapest price across every provider, account arrangement, region, request size, or future date. Check the route you intend to use rather than comparing against a rate that does not apply to your workload.

Calculate input, cache reads, and output separately

With token counts expressed in millions:

Token subtotal = uncached input × input rate + cached input × cached-input rate + output × output rate.

If your usage record reports a total input count that includes cached tokens, subtract the cached portion before multiplying by the uncached rate. Otherwise the estimate charges the same input twice.

For a request sequence without cache hits, a one-million-input, 200,000-output workload costs $3.20 at the displayed direct base rates. Applying cheapaimodel's displayed rates produces $0.3183328, or approximately $0.32.

Here are three explicit scenarios:

Aggregate workload Direct base-rate subtotal Gateway subtotal
1M uncached input + 0.2M output $3.20 $0.32
15M uncached input + 4M output $54.00 $5.37
45M uncached + 180M cached input + 22.5M output $315.00 $31.34

The last row assumes 225 million total input tokens with an 80% cache-hit share. It is a hypothetical cache mix, not a measured or guaranteed hit rate. The first two rows assume no cache hits.

These are aggregate counts across requests, not prompts containing millions of tokens. The direct calculations assume every request qualifies for the base-rate tier. Totals are rounded only after calculation and exclude taxes where applicable, separately billed tools, and other charges beyond the specified token categories. Retries must be included in the token counts if you want them included in the estimate.

The table isolates token prices. It does not show that each route produces the same number of tokens, performs equally, or completes the same number of useful tasks.

A context limit is not a flat-price promise

The official model page lists a 500,000-token context window while separately marking a higher-context pricing boundary above 200K. Those are different concepts: maximum supported size and the conditions for a pricing tier.

Before sending long documents, check the applicable request-size definition, rate tier, and limits for your endpoint. Do not assume that a route advertising the same model and context length must charge exactly the same way.

For a gateway, verify its own billing rules instead of importing the direct provider's terms. If the public rate card does not answer a long-context question, resolve it before making a large request. A successful short request does not validate the price or behavior of a much larger one.

To reduce unnecessary context, identify which documents or conversation turns are relevant to the current task. Compare a smaller prompt against your acceptance criteria rather than removing context solely to reach a lower token number. Missing evidence can cause retries that erase the apparent saving.

Tools can add another billing dimension

An agent can make several model calls and invoke additional services before returning one answer. Consult the official tools documentation for the tools you use and their current pricing rules.

Distinguish a model requesting a function that your application executes from a provider-hosted tool with its own billing. Your application's database, search service, or execution environment may also create costs outside the model invoice.

A useful task ledger records model-token charges, separately billed tools, retries, and external services. It should also record whether the result met the acceptance criteria. Comparing only the final answer's visible text can miss much of the work required to produce it.

Do not assume every tool documented for direct access is exposed by a gateway. Verify the selected route's capabilities and charges independently.

Choose the access route before creating a key

For direct access, use the official API quickstart. For cheapaimodel, use its developer documentation and model catalog. The gateway currently lists the model identifier grok-4.7 and publishes the base URL https://api.cheapaimodel.ai/v1.

A key belongs to the service that issued it. Do not send a direct-provider key to a different gateway or assume a consumer subscription supplies API credit. Confirm the product and billing account attached to the key you create.

cheapaimodel describes prepaid US-dollar billing with top-ups starting at $5 and no subscription. Review its current billing and refund conditions before funding an account. The amount added to a wallet and the cost of an individual request are separate numbers.

Evaluate the workload, not just the price table

Before moving production traffic, choose representative tasks and define success. For document extraction, that might mean correct fields supported by the source. For coding, it might mean passing specific tests without introducing regressions.

Compare total cost per accepted result, including retries and any human corrections. Track latency and failure modes separately. A cheaper token rate is useful only when the application still meets its requirements.

Validate features you rely on, such as streaming, tool calls, or structured output, with your chosen endpoint. This guide supplies pricing arithmetic and evaluation steps; it does not claim that those features have been tested through your account.

If you are still choosing a model family, our LLM API price comparison shows how different input, output, and cache mixes change the budget. Return to the live pricing page before increasing usage, and use actual usage records to replace the assumptions in your estimate.

All posts