Grok API: send the encrypted reasoning back every turn
On xAI's Responses API, append every output item (including encrypted reasoning) to the next request. Dropping it hurts quality and cache hits.
xAI’s best-practices guide says to use the Responses API (Chat Completions is deprecated) and keep the model’s reasoning in the conversation.
Two ways
- Chain requests with
previous_response_id(withstoreon, the default). - Or
store: falseand append everyoutputitem, includingreasoningitems withencrypted_content, to the next request’sinput.
Common ways code drops it
- Extracting only
output_textand re-adding it as a plain message. - Editing, filtering or reordering output items.
- Rebuilding history in Chat Completions format between turns.
Cheaper too
Give each conversation its own prompt_cache_key and only append. Missing reasoning items are the most common cause of cache misses.