Realtime Sessions
Gemini Live API üzerinden düşük gecikmeli sesli/görsel oturumlar için gateway signed WebSocket URL üretir. İstemci bu URL’ye bağlanır, Gemini Live setup ve client mesajlarını gönderir; faturalandırma Live API usage metadata’sına göre hesaplanır.
Oturum oluşturma
Section titled “Oturum oluşturma”curl https://llmtr.com/v1/realtime/sessions \ -H "Authorization: Bearer sk_your_key" \ -H "Content-Type: application/json" \ -d '{ "model": "google/gemini-3.1-flash-live-preview", "max_duration_seconds": 120, "max_budget_usd": 1.50 }'Yanıt:
{ "session_id": "sess_xxx", "ws_url": "wss://realtime.llmtr.com/ws/sess_xxx?token=...", "expires_at": 1739200120}WebSocket bağlantısı
Section titled “WebSocket bağlantısı”ws_url değerine WebSocket client ile bağlanın. İlk mesajınız Gemini Live setup mesajı olmalıdır:
{ "setup": { "generationConfig": { "responseModalities": ["AUDIO"] } }}Sonrasında audio chunk’ları, text parts veya tool responses gönderebilirsiniz.
Parametreler
Section titled “Parametreler”| Alan | Açıklama |
|---|---|
max_duration_seconds | Oturum maksimum süresi |
max_budget_usd | Maksimum harcama limiti (bu limit aşılınca oturum kapatılır) |
response_modalities | ["AUDIO"], ["TEXT"], veya her ikisi |
Faturalandırma
Section titled “Faturalandırma”Rough duration estimate kullanılmaz — Live API’nin döndüğü usageMetadata değerleri üzerinden gerçek input/output token ve ses saniyesi bazında faturalanır.