Maintaining Session for a Chat Conversation in Gemini API (Multi-turn conversations)

Is it possible to maintain a chat session for a certain conversation so that I will not have to send the chat history if i have to send a new message in that same conversation? Does Gemini maintain any state or is it stateless? And if I continuously send the previous conversations will I cost more tokens?

Code:
client = genai.Client(api_key=settings.GEMINI_API_KEY)
chat = self.client.chats.create(
model=model,
config=config,
history=self.chat_history,
)
response = chat.send_message(contents)

1 Like

Continuing the discussion from Maintaining Session for a Chat Conversation in Gemini API (Multi-turn conversations):