How does Restate help?
To implement stateful entities like chat sessions, or stateful agents, Restate provides Virtual Objects. Each Virtual Object instance maintains isolated state and is identified by a unique key. Virtual Objects let you build durable chat sessions that maintain conversation state across multiple interactions, survive process restarts, and handle concurrent messages gracefully.
- Durable state: Conversation history persists across failures and restarts
- Session isolation: Each chat gets isolated state with automatic concurrency control
- Works with any LLM SDK (Vercel AI, LangChain, LiteLLM, etc.) and any programming language supported by Restate (TypeScript, Python, Go, etc.).
- Message ordering: Concurrent messages are queued and processed sequentially

Example
Use Virtual Objects to create persistent chat sessions. Each session is identified by a key (user_id or session_id) and maintains conversation state across multiple interactions.
Run the example
Run the example
1
Requirements
- AI SDK of your choice (e.g., OpenAI, LangChain, Pydantic AI, LiteLLM, etc.) to make LLM calls.
- API key for your model provider.
2
Download the example
3
Start the Restate Server
4
Start the Service
Export the API key of your model provider as an environment variable and then start the agent. For example, for OpenAI:
5
Register the services
- UI
- CLI

6
Send messages to a chat session
- UI
- curl
In the UI (
http://localhost:9070), click on the on_message handler of the Chat service to open the playground.
Enter a key for the chat session (e.g., session123) and send messages to start a conversation.
7
Check the Restate UI
In the State Tab, you can view what is stored in Restate for each chat session:
