Gemini Live API ऑडियो या टेक्स्ट की लगातार स्ट्रीम को प्रोसेस करता है. इन्हें सेशन कहा जाता है. सेशन के लाइफ़साइकल को मैनेज किया जा सकता है. इसमें, शुरुआती हैंडशेक से लेकर, सेशन को सही तरीके से खत्म करने तक की प्रोसेस शामिल है.
सेशन की सीमाएं
Live API के लिए, सेशन का मतलब है ऐसा कनेक्शन जो लगातार बना रहता है. इसमें, इनपुट और आउटपुट को लगातार स्ट्रीम किया जाता है.
अगर सेशन, इनमें से किसी भी सीमा से ज़्यादा होता है, तो कनेक्शन खत्म हो जाता है. हालांकि, ध्यान दें कि Live API सेशन से जुड़ी इन सीमाओं को मैनेज करने के लिए कुछ विकल्प उपलब्ध कराता है. इनकी जानकारी नीचे दी गई है.
सेशन कॉन्टेक्स्ट विंडो की सीमा 1.28 लाख टोकन है.
कॉन्टेक्स्ट विंडो की इस सीमा की वजह से, इनपुट के तरीकों के आधार पर सेशन की ज़्यादा से ज़्यादा अवधि यहां दी गई है:
- सिर्फ़ ऑडियो इनपुट वाले सेशन,
15 मिनट तक सीमित हैं. - वीडियो और ऑडियो इनपुट वाले सेशन,
दो मिनट तक सीमित हैं.
- सिर्फ़ ऑडियो इनपुट वाले सेशन,
कनेक्शन की अवधि करीब
10 मिनट तक सीमित है.कनेक्शन खत्म होने से करीब
60 सेकंड पहले, आपको कनेक्शन खत्म होने की सूचना मिलेगी.
सेशन से जुड़ी सीमाओं को मैनेज करने के लिए, यहां कुछ विकल्प दिए गए हैं:
सेशन कॉन्टेक्स्ट विंडो को कंप्रेस करें ताकि सर्वर, कॉन्टेक्स्ट के साइज़ को सीमा के अंदर अपने-आप बनाए रखे.
सेशन को फिर से शुरू करें नेटवर्क के कुछ समय के लिए डिसकनेक्ट होने या कनेक्शन खत्म होने की सूचना मिलने के बाद, बातचीत के कॉन्टेक्स्ट को बनाए रखने के लिए.
सेशन शुरू करना
सेशन शुरू करने का तरीका दिखाने वाले पूरे स्निपेट के लिए, के लिए शुरुआती निर्देश देखें. Live API
सेशन के दौरान अपडेट करना
Live API मॉडल, सेशन के दौरान अपडेट करने के लिए, ये बेहतर सुविधाएं उपलब्ध कराते हैं:
सिस्टम के निर्देशों को अपडेट करना (सिर्फ़ Vertex AI Gemini API के लिए)
इंक्रीमेंटल कॉन्टेंट अपडेट जोड़ना
चालू सेशन के दौरान, इंक्रीमेंटल अपडेट जोड़े जा सकते हैं. इसका इस्तेमाल, टेक्स्ट इनपुट भेजने, सेशन का कॉन्टेक्स्ट सेट अप करने या सेशन के कॉन्टेक्स्ट को बहाल करने के लिए किया जा सकता है.
बड़े कॉन्टेक्स्ट के लिए, हमारा सुझाव है कि एक मैसेज का सारांश उपलब्ध कराएं, ताकि बाद की बातचीत के लिए कॉन्टेक्स्ट विंडो खाली हो जाए.
छोटे कॉन्टेक्स्ट के लिए, इवेंट के सटीक क्रम को दिखाने के लिए, बारी-बारी से बातचीत भेजी जा सकती है. जैसे, नीचे दिया गया स्निपेट.
Swift
// Define initial turns (history/context).
let turns: [ModelContent] = [
ModelContent(role: "user", parts: [TextPart("What is the capital of France?")]),
ModelContent(role: "model", parts: [TextPart("Paris")]),
]
// Send history, keeping the conversational turn OPEN (false).
await session.sendContent(turns, turnComplete: false)
// Define the new user query.
let newTurn: [ModelContent] = [
ModelContent(role: "user", parts: [TextPart("What is the capital of Germany?")]),
]
// Send the final query, CLOSING the turn (true) to trigger the model response.
await session.sendContent(newTurn, turnComplete: true)
Kotlin
Not yet supported for Android apps - check back soon!
Java
Not yet supported for Android apps - check back soon!
Web
const turns = [{ text: "Hello from the user!" }];
await session.send(
turns,
false // turnComplete: false
);
console.log("Sent history. Waiting for next input...");
// Define the new user query.
const newTurn [{ text: "And what is the capital of Germany?" }];
// Send the final query, CLOSING the turn (true) to trigger the model response.
await session.send(
newTurn,
true // turnComplete: true
);
console.log("Sent final query. Model response expected now.");
Dart
// Define initial turns (history/context).
final List turns = [
Content(
"user",
[Part.text("What is the capital of France?")],
),
Content(
"model",
[Part.text("Paris")],
),
];
// Send history, keeping the conversational turn OPEN (false).
await session.send(
input: turns,
turnComplete: false,
);
// Define the new user query.
final List newTurn = [
Content(
"user",
[Part.text("What is the capital of Germany?")],
),
];
// Send the final query, CLOSING the turn (true) to trigger the model response.
await session.send(
input: newTurn,
turnComplete: true,
);
Unity
// Define initial turns (history/context).
List turns = new List {
new ModelContent("user", new ModelContent.TextPart("What is the capital of France?") ),
new ModelContent("model", new ModelContent.TextPart("Paris") ),
};
// Send history, keeping the conversational turn OPEN (false).
foreach (ModelContent turn in turns)
{
await session.SendAsync(
content: turn,
turnComplete: false
);
}
// Define the new user query.
ModelContent newTurn = ModelContent.Text("What is the capital of Germany?");
// Send the final query, CLOSING the turn (true) to trigger the model response.
await session.SendAsync(
content: newTurn,
turnComplete: true
);
सेशन के दौरान, सिस्टम के निर्देशों को अपडेट करना
| यह सुविधा सिर्फ़ तब उपलब्ध होती है, जब Vertex AI Gemini API को अपने एपीआई प्रोवाइडर के तौर पर इस्तेमाल किया जा रहा हो. |
चालू सेशन के दौरान, सिस्टम के निर्देशों को अपडेट किया जा सकता है. इसका इस्तेमाल, मॉडल के जवाबों में बदलाव करने के लिए किया जा सकता है. जैसे, जवाब की भाषा बदलना या टोन में बदलाव करना.
सेशन के दौरान, सिस्टम के निर्देशों को अपडेट करने के लिए, system रोल के साथ टेक्स्ट कॉन्टेंट भेजा जा सकता है. अपडेट किए गए सिस्टम के निर्देश, सेशन के बाकी समय के लिए लागू रहेंगे.
Swift
await session.sendContent(
[ModelContent(
role: "system",
parts: [TextPart("new system instruction")]
)],
turnComplete: false
)
Kotlin
Not yet supported for Android apps - check back soon!
Java
Not yet supported for Android apps - check back soon!
Web
Not yet supported for Web apps - check back soon!
Dart
try {
await _session.send(
input: Content(
'system',
[Part.text('new system instruction')],
),
turnComplete: false,
);
} catch (e) {
print('Failed to update system instructions: $e');
}
Unity
try
{
await session.SendAsync(
content: new ModelContent(
"system",
new ModelContent.TextPart("new system instruction")
),
turnComplete: false
);
}
catch (Exception e)
{
Debug.LogError($"Failed to update system instructions: {e.Message}");
}
कॉन्टेक्स्ट विंडो को कंप्रेस करना
|
इस पेज पर, प्रोवाइडर के हिसाब से कॉन्टेंट और कोड देखने के लिए, अपने Gemini API प्रोवाइडर पर क्लिक करें. |
Live API सेशन कॉन्टेक्स्ट विंडो में, रीयल-टाइम स्ट्रीम किया गया डेटा (ऑडियो के लिए हर सेकंड 25 टोकन (टीपीएस) और वीडियो के लिए 258 टीपीएस) सेव होता है. इसके अलावा, इसमें अन्य कॉन्टेंट भी सेव होता है. जैसे, टेक्स्ट इनपुट और मॉडल आउटपुट. सभी Live API मॉडल के लिए, सेशन कॉन्टेक्स्ट विंडो की सीमा 1.28 लाख टोकन है.
डिफ़ॉल्ट रूप से, कॉन्टेक्स्ट विंडो की इस सीमा की वजह से, इनपुट के तरीकों के आधार पर सेशन की ज़्यादा से ज़्यादा अवधि यहां दी गई है:
- सिर्फ़ ऑडियो इनपुट वाले सेशन,
15 मिनट तक सीमित हैं. - वीडियो और ऑडियो इनपुट वाले सेशन,
दो मिनट तक सीमित हैं.
लंबे समय तक चलने वाले सेशन में, बातचीत आगे बढ़ने के साथ-साथ, ऑडियो और/या वीडियो टोकन का इतिहास इकट्ठा होता जाता है. अगर यह इतिहास, मॉडल की सीमा से ज़्यादा हो जाता है, तो मॉडल गलत जवाब दे सकता है, उसकी स्पीड कम हो सकती है या सेशन को ज़बरदस्ती खत्म किया जा सकता है.
लंबे सेशन चालू करने के लिए, कॉन्टेक्स्ट विंडो कंप्रेस करने की सुविधा चालू की जा सकती है. इसके लिए, LiveGenerationConfig के हिस्से के तौर पर, contextWindowCompression फ़ील्ड को सेट करें. यह सुविधा चालू होने पर, सर्वर स्लाइडिंग-विंडो मैकेनिज़्म का इस्तेमाल करके, सबसे पुराने टर्न को अपने-आप खारिज कर देता है या उन्हें सारांशित कर देता है, ताकि कॉन्टेक्स्ट का साइज़, डिफ़ॉल्ट या तय की गई सीमाओं के अंदर बना रहे. सिस्टम के निर्देश खारिज नहीं किए जाते और वे हमेशा कॉन्टेक्स्ट विंडो की शुरुआत में रहेंगे.
उपयोगकर्ता के नज़रिए से, इससे सेशन की अवधि को सिद्धांत के तौर पर, हमेशा के लिए बढ़ाया जा सकता है, क्योंकि "मेमोरी" को लगातार मैनेज किया जाता है.
स्लाइडिंग-विंडो मैकेनिज़्म के साथ-साथ, कंप्रेस करने की प्रोसेस को ट्रिगर करने वाले टोकन की संख्या को भी वैकल्पिक तौर पर कॉन्फ़िगर किया जा सकता है. इसके लिए, उपलब्ध सेटिंग और वैल्यू नीचे देखें. इन सेटिंग का इस्तेमाल करने के बारे में, यहां कुछ अहम बातें दी गई हैं:
targetTokensको बहुत कम पर सेट करने से, लगातार स्ट्रीम के लिए ज़्यादा कॉन्टेक्स्ट रूम खाली हो जाएगा. हालांकि, मॉडल बातचीत के पुराने टर्न को तेज़ी से "भूल" जाएगा.targetTokensकोtriggerTokensके करीब सेट करने से, ज़्यादा मेमोरी सेव रहेगी. हालांकि, कंप्रेस करने की रूटीन बहुत ज़्यादा बार ट्रिगर होंगी.
| सेटिंग | कॉन्फ़िगरेशन में सेट न होने पर, स्लाइडिंग विंडो के लिए डिफ़ॉल्ट वैल्यू | कम से कम मान | अधिकतम मान |
|---|---|---|---|
triggerTokensकंप्रेस करने की प्रोसेस ट्रिगर होने से पहले, कॉन्टेक्स्ट की लंबाई |
मॉडल की कॉन्टेक्स्ट विंडो की सीमा का 80% | 5,000 | 1,28,000 |
targetTokensरखे जाने वाले टोकन की टारगेट संख्या |
triggerTokens वैल्यू का 50%
|
0 | 1,28,000 |
Swift
// Initialize the Gemini Developer API backend service
let liveModel = FirebaseAI.firebaseAI(backend: .googleAI()).liveModel(
modelName: "gemini-2.5-flash-native-audio-preview-12-2025",
// Enable context window compression.
// (Optional) Configure the number of tokens in the context window that triggers the compression.
generationConfig: LiveGenerationConfig(
responseModalities: [.audio],
contextWindowCompression: ContextWindowCompressionConfig(
triggerTokens: 10000,
slidingWindow: SlidingWindow(
targetTokens: 2000,
)
)
)
)
Kotlin
// Initialize the Gemini Developer API backend service
val liveModel = Firebase.ai(backend = GenerativeBackend.googleAI()).liveModel(
modelName = "gemini-2.5-flash-native-audio-preview-12-2025",
// Enable context window compression.
// (Optional) Configure the number of tokens in the context window that triggers the compression.
generationConfig = liveGenerationConfig {
responseModality = ResponseModality.AUDIO,
contextWindowCompression = ContextWindowCompressionConfig(
triggerTokens = 10000,
slidingWindow = SlidingWindow(targetTokens = 2000)
)
}
)
Java
// Initialize the Gemini Developer API backend service
LiveGenerativeModel lm = FirebaseAI.getInstance(GenerativeBackend.googleAI()).liveModel(
"gemini-2.5-flash-native-audio-preview-12-2025",
// Enable context window compression.
// (Optional) Configure the number of tokens in the context window that triggers the compression.
new LiveGenerationConfig.Builder()
.setResponseModality(ResponseModality.AUDIO)
.setContextWindowCompression(
new ContextWindowCompressionConfig(10000, new SlidingWindow(2000))
)
.build()
);
Web
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
const liveModel = getLiveGenerativeModel(ai, {
model: "gemini-2.5-flash-native-audio-preview-12-2025",
// Enable context window compression.
// (Optional) Configure the number of tokens in the context window that triggers the compression.
generationConfig: {
responseModalities: [ResponseModality.AUDIO],
contextWindowCompression: {
triggerTokens: 10000,
slidingWindow: {
targetTokens: 2000,
},
},
},
});
Dart
final _liveModel = FirebaseAI.googleAI().liveGenerativeModel(
model: 'gemini-2.5-flash-native-audio-preview-12-2025',
// Enable context window compression.
// (Optional) Configure the number of tokens in the context window that triggers the compression.
liveGenerationConfig: LiveGenerationConfig(
responseModalities: [ResponseModalities.audio],
contextWindowCompression: ContextWindowCompressionConfig(
triggerTokens: 10000,
slidingWindow: SlidingWindow(targetTokens: 2000),
),
),
);
Unity
var liveModel = FirebaseAI.GetInstance(FirebaseAI.Backend.GoogleAI()).GetLiveModel(
modelName: "gemini-2.5-flash-native-audio-preview-12-2025",
// Enable context window compression.
// (Optional) Configure the number of tokens in the context window that triggers the compression.
liveGenerationConfig: new LiveGenerationConfig(
responseModalities: new[] { ResponseModality.Audio },
contextWindowCompression: new ContextWindowCompressionConfig(
triggerTokens: 10000,
slidingWindow: new SlidingWindow(targetTokens: 2000)
)
)
);
यह पता लगाना कि सेशन कब खत्म होने वाला है
एक बार में, लगातार WebSocket कनेक्शन की ज़्यादा से ज़्यादा अवधि करीब
यहां दिए गए उदाहरण में, कनेक्शन खत्म होने की सूचना सुनकर, कनेक्शन खत्म होने का पता लगाने का तरीका बताया गया है:
Swift
for try await response in session.responses {
switch response.payload {
case .goingAwayNotice(let goingAwayNotice):
// Prepare for the session to close soon
if let timeLeft = goingAwayNotice.timeLeft {
print("Server going away in \(timeLeft) seconds")
}
}
}
Kotlin
for (response in session.responses) {
when (val message = response.payload) {
is LiveServerGoAway -> {
// Prepare for the session to close soon
val remaining = message.timeLeft
logger.info("Server going away in $remaining")
}
}
}
Java
session.getResponses().forEach(response -> {
if (response.getPayload() instanceof LiveServerResponse.GoingAwayNotice) {
LiveServerResponse.GoingAwayNotice notice = (LiveServerResponse.GoingAwayNotice) response.getPayload();
// Prepare for the session to close soon
Duration timeLeft = notice.getTimeLeft();
}
});
Web
for await (const message of session.receive()) {
switch (message.type) {
...
case "goingAwayNotice":
console.log("Server going away. Time left:", message.timeLeft);
break;
}
}
Dart
Future _handleLiveServerMessage(LiveServerResponse response) async {
final message = response.message;
if (message is GoingAwayNotice) {
// Prepare for the session to close soon
developer.log('Server going away. Time left: ${message.timeLeft}');
}
}
Unity
foreach (var response in session.Responses) {
if (response.Payload is LiveSessionGoingAway notice) {
// Prepare for the session to close soon
TimeSpan timeLeft = notice.TimeLeft;
Debug.Log($"Server going away notice received. Remaining: {timeLeft}");
}
}
सेशन फिर से शुरू करना
Live API सेशन को फिर से शुरू करने की सुविधा उपलब्ध कराता है, ताकि बातचीत का कॉन्टेक्स्ट बना रहे. हर सेशन का एक हैंडल होता है. इसका इस्तेमाल इन तरीकों से किया जा सकता है:
कनेक्शन की समयसीमा खत्म होने से पहले, सेशन को बनाए रखना
एक बार में, लगातार WebSocket कनेक्शन की ज़्यादा से ज़्यादा अवधि करीब
10 मिनट होती है. _कनेक्शन खत्म होने की सूचना_ सुनकर, यह पता लगाया जा सकता है कि कनेक्शन कब खत्म होने वाला है.इसके बाद, सेशन हैंडल का इस्तेमाल करके, नया कनेक्शन बनाकर सेशन को बढ़ाया जा सकता है.कनेक्शन ड्रॉप होने के तुरंत बाद, सेशन को फिर से शुरू करना
अगर कनेक्शन की समयसीमा खत्म होने से पहले, कनेक्शन खत्म हो जाता है या ड्रॉप हो जाता है (उदाहरण के लिए, वाई-फ़ाई से 5G पर स्विच करना), तो सर्वर, सेशन की स्थिति को करीब
10 मिनट तक बनाए रखता है. इस दौरान, सेशन हैंडल का इस्तेमाल करके, नया कनेक्शन बनाकर सेशन को फिर से शुरू किया जा सकता है.काफ़ी समय बाद, सेशन को फिर से शुरू करना
कनेक्शन खत्म होने के बाद, सर्वर, सेशन की स्थिति को कुछ घंटों तक बनाए रखता है. इस दौरान, सेशन हैंडल का इस्तेमाल करके, नया कनेक्शन बनाकर सेशन को फिर से शुरू किया जा सकता है. ध्यान दें कि यह समय दो Gemini API प्रोवाइडर के लिए अलग-अलग होता है: Gemini Developer API के लिए
दो घंटे | Vertex AI Gemini API के लिए24 घंटे .
डिफ़ॉल्ट रूप से, सेशन को फिर से शुरू करने की सुविधा बंद होती है. सेशन को फिर से शुरू करने की सुविधा चालू करने के लिए, नया कनेक्शन बनाते समय, फिर से शुरू करने के लिए खाली कॉन्फ़िगरेशन पास करें. यह सुविधा चालू होने पर, सर्वर समय-समय पर अपडेट भेजता है. इनमें, सेशन को फिर से शुरू करने का हैंडल शामिल होता है. अगर सेशन डिसकनेक्ट हो जाता है, तो फिर से कनेक्ट किया जा सकता है और इस हैंडल को पास करके, सेशन को उसके कॉन्टेक्स्ट के साथ फिर से शुरू किया जा सकता है.
यहां दिए गए उदाहरणों में, सेशन को फिर से शुरू करने के दो विकल्प दिखाए गए हैं:
Swift
// Local variable to save the active session handle
var activeSessionHandle: String?
// Initialize the session. Passing an empty config requests the server to send SessionResumptionUpdate
var session = try await liveModel.connect(
sessionResumption: SessionResumptionConfig()
)
// Start receiving responses
for try await message in session.responses {
// Check for new session handles inside your message handling loop
switch message.payload {
case let .sessionResumptionUpdate(updateMessage):
guard let newHandle = updateMessage.newHandle, updateMessage.resumable else {
continue
}
activeSessionHandle = newHandle
print("SessionResumptionUpdate: handle \(newHandle)")
// ... handle other LiveServerMessage types ...
default:
break
}
}
// The following are alternative options to resume a session. Choose only one.
// Option 1: Create and connect a session to resume with the saved handle
if let handle = activeSessionHandle {
session = try await liveModel.connect(
sessionResumption: SessionResumptionConfig(handle: handle)
)
}
// Option 2: Resume the session directly on an existing session object
if let handle = activeSessionHandle {
try await session.resumeSession(
sessionResumption: SessionResumptionConfig(handle: handle)
)
}
Kotlin
// Local variable to save the active session handle
var activeSessionHandle: String? = null
// Initialize the session. Passing an empty config requests the server to send SessionResumptionUpdate
var session = liveModel.connect(
sessionResumption = SessionResumptionConfig()
)
// Start receiving responses
session.receive().collect { message ->
// Process other received response types...
// Check for new session handles inside your message handling loop
if (message is LiveSessionResumptionUpdate) {
if (message.resumable == true && message.newHandle != null) {
activeSessionHandle = message.newHandle
Log.d("TAG", "SessionResumptionUpdate: handle ${message.newHandle}")
}
}
}
// The following are alternative options to resume a session. Choose only one.
// Option 1: Create and connect a session to resume with the saved handle
activeSessionHandle?.let { handle ->
session = liveModel.connect(
sessionResumption = SessionResumptionConfig(handle = handle)
)
}
// Option 2: Resume the session directly on an existing session object
activeSessionHandle?.let { handle ->
session.resumeSession(
sessionResumption = SessionResumptionConfig(handle = handle)
)
}
Java
For Java, session resumption is not yet supported. Check back soon!
Web
// Local variable to save the active session handle
let activeSessionHandle = null;
// Initialize the session. Passing an empty object requests the server to send SessionResumptionUpdate
let session = await liveModel.connect({});
// Start receiving responses
for await (const message of session.receive()) {
// Process other received response types...
// Check for new session handles inside your message handling loop
if (message.type === 'sessionResumptionUpdate') {
if (message.resumable && message.newHandle) {
activeSessionHandle = message.newHandle;
console.log(`SessionResumptionUpdate: handle ${activeSessionHandle}`);
}
}
}
// The following are alternative options to resume a session. Choose only one.
// Option 1: Create and connect a session to resume with the saved handle
if (activeSessionHandle) {
session = await liveModel.connect({
handle: activeSessionHandle
});
}
// Option 2: Resume the session directly on an existing session object
if (activeSessionHandle) {
await session.resumeSession({
handle: activeSessionHandle
});
}
Dart
// Local variable to save the active session handle
String? _activeSessionHandle;
// Initialize the session. Passing an empty config requests the server to send SessionResumptionUpdate
var _session = await _liveModel.connect(
sessionResumption: SessionResumptionConfig(),
);
// Start receiving responses
await for (final message in _session.receive()) {
// Process other received response types...
// Check for new session handles inside your message handling loop
if (message is SessionResumptionUpdate &&
message.resumable != null &&
message.resumable!) {
_activeSessionHandle = message.newHandle;
log('SessionResumptionUpdate: handle ${message.newHandle}');
}
}
// The following are alternative options to resume a session. Choose only one.
// Option 1: Create and connect a session to resume with the saved handle
if (_activeSessionHandle != null) {
_session = await _liveModel.connect(
sessionResumption: SessionResumptionConfig.resume(_activeSessionHandle!),
);
}
// Option 2: Alternatively, resume the session directly on an existing session object
if (_activeSessionHandle != null) {
await _session.resumeSession(
sessionResumption: SessionResumptionConfig.resume(_activeSessionHandle!),
);
}
Unity
// Local variable to save the active session handle
string activeSessionHandle = null;
// Initialize the session. Passing an empty config requests the server to send SessionResumptionUpdate
var session = await liveModel.ConnectAsync(
sessionResumption: new SessionResumptionConfig()
);
// Start receiving responses
await foreach (var response in session.ReceiveAsync())
{
// Process other received response types...
// Check for new session handles inside your message handling loop
if (response.Message is LiveSessionResumptionUpdate updateMessage)
{
if (updateMessage.Resumable == true && !string.IsNullOrEmpty(updateMessage.NewHandle))
{
activeSessionHandle = updateMessage.NewHandle;
Debug.Log($"SessionResumptionUpdate: handle {activeSessionHandle}");
}
}
}
// The following are alternative options to resume a session. Choose only one.
// Option 1: Create and connect a session to resume with the saved handle
if (!string.IsNullOrEmpty(activeSessionHandle)) {
session = await liveModel.ConnectAsync(
sessionResumption: new SessionResumptionConfig(activeSessionHandle)
);
}
// Option 2: Resume the session directly on an existing session object
if (!string.IsNullOrEmpty(activeSessionHandle)) {
await session.ResumeSessionAsync(
sessionResumption: new SessionResumptionConfig(activeSessionHandle)
);
}