Gemini Chat History

Chat history is with the Gemini API exactly as stateless as with OpenAI. The ChatSession.history property stores a chronological record of the conversation between the user and the Gemini model in-memory and automatically prepends the whole history on each subsequent chat turn. Nothing magic about it. Since it’s in-memory, if the process crashes, it is gone.

To maintain chat history for longer, it is up to the client to store the history object in a database (relational or object database).

Hope that helps!

2 Likes