stateful_chat
Maintain ongoing conversations with persistent server-side history for up to 30 days, allowing you to continue discussions across sessions without managing chat history manually.
Instructions
Have ongoing conversations that are saved on xAI's servers for up to 30 days.
Unlike regular chat, this maintains conversation history server-side, so you can
continue conversations across sessions without managing history yourself. Start a
new conversation without a response_id, then use the returned ID to continue it
later. Super useful for long-running projects or when you want to pick up where
you left off days later.
Args:
prompt: What you want to say in this turn of the conversation
response_id: ID from a previous response to continue that conversation (optional)
model: Which Grok model to use (default is grok-4)
system_prompt: Instructions for the AI (only used when starting new conversation)
include_reasoning: Get a summary of the model's thinking process (default False)
temperature: Controls creativity 0-2
max_tokens: Maximum length of response
Returns a dict with 'content' (the response), 'response_id' (save this to continue
later!), 'status', 'model', 'usage', 'stored_until' (expiration date), and
optionally 'reasoning' if you requested it.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
include_reasoning | No | ||
max_tokens | No | ||
model | No | grok-4 | |
prompt | Yes | ||
response_id | No | ||
system_prompt | No | ||
temperature | No |
Input Schema (JSON Schema)
{
"properties": {
"include_reasoning": {
"default": false,
"title": "Include Reasoning",
"type": "boolean"
},
"max_tokens": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "Max Tokens"
},
"model": {
"default": "grok-4",
"title": "Model",
"type": "string"
},
"prompt": {
"title": "Prompt",
"type": "string"
},
"response_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Response Id"
},
"system_prompt": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "System Prompt"
},
"temperature": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Temperature"
}
},
"required": [
"prompt"
],
"type": "object"
}