In short.
This xAI guide teaches developers how to route Grok requests for better prompt-cache reuse, but it provides no measured results or complete cache-matching rules. It explains that caches are stored per server and shows how to keep related requests routed to the same server. Chat Completions uses x-grok-conv-id in an HTTP header, Responses uses prompt_cache_key in the request body, and gRPC uses x-grok-conv-id metadata. Several examples expose cached-token counters, but cache lifetime, pricing and achievable hit rates remain unknown. Nothing was executed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete selected documentation page at [https://docs.x.ai/developers/advanced-api-usage/prompt-caching/maximizing-cache-hits.md], including all examples and the navigation link to What Breaks Caching. Linked pages, SDK documentation, pricing and service terms are excluded. The selected page supplies no license notice. No code, API request, cache behavior, model availability or billing outcome was tested.
The overview
Identity
Maximizing Cache Hits is a page in xAI's Prompt Caching documentation at [https://docs.x.ai/developers/advanced-api-usage/prompt-caching/maximizing-cache-hits.md]. It is an implementation guide for cache-related request routing, with examples using the OpenAI SDK, the AI SDK xAI provider, curl and the xAI SDK.
Assessment
The guide is useful when integrating xAI APIs and deciding where to place a cache-routing identifier. It supplies concrete request fields and usage-counter paths. Its practical limit is that correct routing alone does not establish whether a particular request will reuse cached tokens; the page supplies neither complete matching rules nor before-and-after measurements.
Users
The likely audience is developers making repeated or conversational requests to Grok. Beginners get examples of credentials, endpoints and request structure, while experienced developers get the exact controls for three API interfaces. The page assumes familiarity with API requests and does not provide a complete account or package-installation tutorial.
Capabilities
The documented controls direct requests sharing an identifier to the same server for cache reuse. Chat Completions takes the x-grok-conv-id HTTP header, Responses takes the prompt_cache_key body field, and the xAI gRPC client takes x-grok-conv-id metadata.
The examples also show cached-token reporting through response.usage.prompt_tokens_details.cached_tokens for Chat Completions, response.usage.input_tokens_details.cached_tokens for Responses, and response.usage.cached_prompt_text_tokens for gRPC.
Using it
Requirements
The examples require an xAI API key and use the model identifier grok-4.7. The OpenAI SDK examples configure the API base as [https://api.x.ai/v1]. Other examples import ai with @ai-sdk/xai, or xai_sdk for gRPC. Required package versions, account entitlements and compatibility with other models are unspecified.
Mechanism
The page states that cache entries are stored separately on each server. Keeping requests routed to the same server therefore improves their opportunity to reuse that server's cache. It describes prompt_cache_key as functioning identically to the Chat Completions header.
The identifier controls routing. The page does not establish that reusing an identifier guarantees a cache hit, nor does it specify the prompt-matching, expiration or eviction rules.
Setup
For Chat Completions, add x-grok-conv-id to the request headers and keep its value consistent across requests intended to share routing. For Responses, put prompt_cache_key in the request body. With the xAI gRPC SDK, supply x-grok-conv-id through the Client metadata argument.
The Python OpenAI SDK Responses example passes prompt_cache_key through extra_body. The JavaScript OpenAI SDK example supplies it directly and includes @ts-expect-error for the provider-specific field. The AI SDK example instead uses providerOptions.xai.promptCacheKey. These naming and placement differences matter when adapting the examples.
Example
The Python Chat Completions example sends the question “What is prompt caching?” to grok-4.7 with x-grok-conv-id set to conv_abc123. It then prints the generated response and the cached-token counter. The Responses examples use prompt_cache_key with a UUID-shaped sample value.
Each snippet shows a single request, so none demonstrates a second request actually hitting a cache. The AI SDK snippet logs totalTokens rather than a cache-specific count. No example was executed.
Assessment & evidence
Limitations
The page does not specify minimum cacheable prompt size, matching requirements, cache lifetime, eviction behavior, routing behavior during server changes or identifier constraints. It links to What Breaks Caching, but that linked page is outside the covered material. Actual cache-hit rates, SDK compatibility and runtime behavior remain unassessed.
Reasoning
Given the documented server-local cache design, consistently routing related requests to one server should improve the opportunity for reuse. This is an inference from the stated architecture, not a measured outcome. The evidence supports the integration instructions but does not quantify their benefit for any workload.
Alternatives
The page offers equivalent routing controls through different xAI interfaces: an HTTP header for Chat Completions, a body field for Responses and metadata for gRPC. A developer can use the control matching the interface already in their application. The page provides no comparison with other providers or caching systems.
Evidence
The source is the complete xAI documentation page at [https://docs.x.ai/developers/advanced-api-usage/prompt-caching/maximizing-cache-hits.md]. It directly supports the routing explanation, parameter names and example usage-counter paths. It contains no execution transcript, observed cache-hit values or benchmark results. Nothing was executed, so operational success is unknown.
Access & freshness
Costs
The page supplies no API prices, cached-token rates, free allowance or cost estimates. Any financial benefit is unknown. Cached-token counts alone do not establish a billing discount, and no measured latency improvement is provided.
Rights
The supplied page includes no license or explicit redistribution permission for its text or code examples. Reuse rights under a particular license are unknown. It also does not establish service terms or rights governing submitted prompts.
Freshness
The source snapshot was captured on November 15, 2026 at 04:42:01.587 UTC. The page gives no publication date, update date or SDK versions. Its examples name grok-4.7; model availability and API behavior beyond this snapshot are unknown.
Actions
Use the routing control appropriate to your API and keep its value consistent across related requests. Before estimating savings, confirm model access, SDK support, cache eligibility rules and current pricing.
For an application evaluation, make repeated requests representative of your workload and record the relevant cached-token counters, latency and billing. These are suggested next steps; no such evaluation was performed.
