You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
xAI caches prompts automatically, but each server keeps its own cache. For a session to benefit, every request needs a stable conversation identifier so the API can route it to the server that holds the session's cache. The identifier is the x-grok-conv-id header, or the prompt_cache_key body field for the Responses API. See the xAI prompt caching docs.
opencode sends neither for xai models:
ProviderTransform.options sets promptCacheKey only for the openai, azure, venice, openrouter, and opencode gpt-5 providers
Setting it for xai would not help on its own. @ai-sdk/xai has no promptCacheKey option, and its Responses options schema removes unknown keys, so the value never reaches the request body. Verified through version 4.0.6
No code path sets x-grok-conv-id
As a result, xai sessions hit the cache only when load balancing happens to return them to the same server. Cached tokens are billed at a reduced rate and return faster, so every miss adds cost and latency.
Plugins
None
OpenCode version
dev (current)
Steps to reproduce
Configure the xai provider with an API key and run any prompt against an xai model
Capture the outgoing request, for example by pointing provider.xai.options.baseURL at a local logging proxy
The /v1/responses request has no x-grok-conv-id header and no prompt_cache_key body field
Screenshot and/or share link
A request captured through a logging proxy shows both identifiers absent on xai /v1/responses requests.
This issue might be a duplicate of, or closely related to, existing issues. Please check:
V2 runner has no native route for @ai-sdk/xai models, dropping prompt cache key #35034: Also filed by you — covers the V2 runner having no native route for @ai-sdk/xai models, which means prompt_cache_key is never sent. The two issues describe overlapping root causes (missing xAI support in the V2 runner + missing cache key propagation) and may be worth consolidating.
Activity
github-actions commentedon Jul 2, 2026
This issue might be a duplicate of, or closely related to, existing issues. Please check:
@ai-sdk/xaimodels, which meansprompt_cache_keyis never sent. The two issues describe overlapping root causes (missing xAI support in the V2 runner + missing cache key propagation) and may be worth consolidating.