---
title: "LiveKit Agents से ThunderPhone का उपयोग करें"
description: "LiveKit Agents सेशन के रियलटाइम (स्पीच-टू-स्पीच) मॉडल के रूप में ThunderPhone वॉइस एजेंट चलाएं, जिसके आसपास LiveKit रूम, SIP और टेलीफोनी हों।"
---

[LiveKit Agents](https://github.com/livekit/agents) LiveKit रूम्स पर रियलटाइम वॉइस एजेंट्स के लिए एक ओपन-सोर्स फ्रेमवर्क है। ThunderPhone **रियलटाइम मॉडल** के रूप में इंटीग्रेट होता है: फ्रेमवर्क प्रतिभागी का ऑडियो भेजता है, ThunderPhone एजेंट की आवाज़, ट्रांसक्रिप्ट्स और फंक्शन कॉल्स लौटाता है, और LiveKit के रूम्स, SIP ट्रंक्स और टेलीफोनी ऑडियो को कैरी करते हैं। स्पीच रिकग्निशन, लैंग्वेज मॉडल, आवाज़, टर्न-टेकिंग, 62 भाषाएँ और टूल्स सभी ThunderPhone पर चलते हैं।

इस तरह किए गए कॉल [कॉल हिस्ट्री](/api-reference/calls) में दिखाई देते हैं और किसी भी अन्य रीयलटाइम कॉल की तरह बिल किए जाते हैं ([मूल्य निर्धारण](/hi/guides/pricing))। इसमें कोई सब्सक्रिप्शन या ThunderPhone फ़ोन नंबर शामिल नहीं है।

## इंस्टॉल करें

```bash
pip install livekit-plugins-thunderphone
export THUNDERPHONE_API_KEY=sk_live_...   # a secret API key
```

uv के साथ, `uv add "livekit-agents[thunderphone]~=1.8"` वही
प्लगइन इंस्टॉल करता है। यह [livekit/agents](https://github.com/livekit/agents)
रिपॉजिटरी में शामिल है और `livekit-agents` के साथ ही रिलीज़ होता है, इसलिए दोनों को
एक ही वर्ज़न पर रखें। LiveKit इसे अपने
[ThunderPhone प्लगइन गाइड](https://docs.livekit.io/agents/models/realtime/thunderphone/) में डॉक्यूमेंट करता है।

प्लगइन LiveKit के OpenAI Realtime मॉडल को रैप करता है, क्योंकि ThunderPhone का
[Realtime WebSocket](/api-reference/realtime) वही प्रोटोकॉल बोलता है। इसके लिए
`livekit-agents` 1.8 या नया वर्जन चाहिए।

## सेव किया गया एजेंट चलाएं

एजेंट जो कुछ भी करता है (प्रॉम्प्ट, वॉइस, इंजन, भाषाएँ, टूल, अभिवादन,
साइलेंस चेक-इन) ThunderPhone पर कॉन्फ़िगर किया जाता है। सेशन केवल ऑडियो स्थानांतरित करता है।
एजेंट को डैशबोर्ड में बनाएं, या Zeus (ThunderPhone एजेंटों को बनाने, टेस्ट करने
और ट्यून करने वाला AI एजेंट) से इसे सेट अप करवाएं, फिर उसका ID यहाँ पास करें। ThunderPhone पर
डिप्लॉय किए गए बदलाव आपके LiveKit कोड को छुए बिना अगली कॉल पर लागू होते हैं।

```python
from livekit.agents import Agent, AgentSession, JobContext, WorkerOptions, cli
from livekit.plugins import thunderphone


async def entrypoint(ctx: JobContext):
    session = AgentSession(llm=thunderphone.RealtimeModel(agent_id=12))
    await session.start(agent=Agent(instructions=""), room=ctx.room)


if __name__ == "__main__":
    cli.run_app(WorkerOptions(entrypoint_fnc=entrypoint))
```

एक सेव किया गया एजेंट ThunderPhone पर ग्रीट करता है और अपने टूल्स चलाता है; LiveKit
`Agent` के निर्देश और टूल्स नहीं भेजे जाते। ThunderPhone एजेंट के कॉल समाप्त करने पर
कॉल समाप्त होती है, और सेशन उसके साथ बंद हो जाता है।

## सेशन को इनलाइन कॉन्फ़िगर करें

`agent_id` के बिना, निर्देश और टूल LiveKit `Agent` से आते हैं, ठीक उसी तरह जैसे वे OpenAI के लिए आते हैं। `model` इंजन चुनता है और `voice` ThunderPhone की आवाज़ चुनता है।

```python
from livekit.agents import Agent, AgentSession, RunContext, function_tool
from livekit.plugins import thunderphone


class Receptionist(Agent):
    def __init__(self):
        super().__init__(instructions="You are Acme Dental's receptionist. Be brief.")

    @function_tool
    async def check_availability(self, context: RunContext, date: str) -> dict:
        """Free appointment slots on a date."""
        return {"slots": await calendar.free_slots(date)}


async def entrypoint(ctx: JobContext):
    session = AgentSession(
        llm=thunderphone.RealtimeModel(model="bolt", voice="olivia", language="es"),
    )
    await session.start(agent=Receptionist(), room=ctx.room)
    await session.generate_reply()   # the agent speaks first
```

ThunderPhone कॉल शुरू होने पर निर्देशों और टूल्स को फ्रीज़ कर देता है, इसलिए
उन्हें बदलने वाले `update_instructions`, `update_tools` और एजेंट हैंड-ऑफ्स
कॉल के दौरान समर्थित नहीं हैं। इनलाइन सेशंस क्लाइंट-नियंत्रित होते हैं: एजेंट तब बोलता है
जब आप `generate_reply()` कॉल करते हैं या जब प्रतिभागी अपना टर्न पूरा करता है।

## विकल्प

| आर्ग्युमेंट | अर्थ |
|---|---|
| `api_key` | सीक्रेट की (`sk_live_...`)। डिफ़ॉल्ट रूप से `THUNDERPHONE_API_KEY` का उपयोग होता है। |
| `agent_id` | सेव किए गए एजेंट को चलाएँ। `model` और `voice` के साथ परस्पर अनन्य है। |
| `model` | इनलाइन सेशंस के लिए इंजन: `bolt` (पुराने `spark` और `storm` अभी भी स्वीकार किए जाते हैं)। |
| `voice` | इनलाइन सेशंस के लिए ThunderPhone वॉइस नाम। |
| `language` | इनलाइन सेशंस के लिए प्राथमिक भाषा संकेत, जैसे `es`। |
| `caller_number`, `callee_number` | जब रूम किसी फोन लाइन को फ्रंट करता है, तब कॉल के फोन नंबर। ये कॉल हिस्ट्री में from और to नंबरों के रूप में दिखाई देते हैं। |
| `live_transcripts` | कॉलर के ट्रांसक्रिप्ट फ़्रैगमेंट्स को बोलते समय स्ट्रीम करें (अतिरिक्त बिल किया जाता है)। |
| `base_url` | एंडपॉइंट ओवरराइड, डिफ़ॉल्ट `wss://api.thunderphone.com/v1/realtime`। |

## इवेंट्स

ThunderPhone रियलटाइम प्रोटोकॉल के ऊपर प्लेटफ़ॉर्म इवेंट्स जोड़ता है। सेशन
इन्हें एमिट करता है:

```python
@session.llm.session.on("thunderphone_call_ended")  # or on the RealtimeSession you hold
def on_call_ended(event):
    print("call ended:", event["reason"])
```

सेशन लाइव होने पर `RealtimeSession`, `call_id` एक्सपोज़ करता है। कॉल के बाद
रिकॉर्डिंग, ट्रांसक्रिप्ट और ग्रेड प्राप्त करने के लिए इसका उपयोग
[`GET /v1/calls/{call_id}`](/api-reference/calls) के साथ करें। हर अन्य `call.*` इवेंट (ट्रांसफ़र,
कीपैड, स्पीच इग्नोर्ड) `thunderphone_call_event` के रूप में आता है।

## सीमाएँ

- टर्न डिटेक्शन सर्वर-साइड है और हमेशा चालू रहता है; फ़्रेमवर्क-साइड टर्न डिटेक्शन
  (`AgentSession` पर `turn_detection`) को अनदेखा किया जाता है।
- कॉल शुरू होने के बाद इंस्ट्रक्शंस और टूल्स बदले नहीं जा सकते।
- ऑडियो दोनों दिशाओं में 24 kHz पर 16-बिट मोनो PCM है।
- वीडियो फ़्रेम्स को अनदेखा किया जाता है।

<Note>
क्या आप इसके बजाय Pipecat पर बना रहे हैं? [Pipecat से ThunderPhone का उपयोग करें](/hi/guides/use-with-pipecat) देखें।
</Note>
