Skip to content
Docs
Guides

Build with Python

Issue a room grant with FastAPI, join a room from Python, or run a standalone or Pipecat voice agent.

Choose the package for the work your Python process does. Use Python 3.11 or later in a virtual environment.

Task Install Source and example
Issue tokens, administer rooms, verify webhooks or use Cloud AI services python -m pip install dtelecom-server-sdk Cloud SDK · FastAPI issuer
Join a room to publish or receive audio and room data python -m pip install dtelecom-rtc RTC SDK · PCM audio example
Build a standalone voice agent with an LLM python -m pip install 'dtelecom-agents[llm]' Agents SDK · Voice agent
Use room audio or dTelecom speech in a Pipecat pipeline python -m pip install 'dtelecom-pipecat[rtc]' Pipecat integration · Room agent

Set DTELECOM_API_KEY and DTELECOM_API_SECRET on your backend using credentials from your Cloud project. Set DTELECOM_CLOUD_URL=https://cloud.dtelecom.org. Your application authenticates the user and supplies their room and participant identity.

from dtelecom_server import CloudClient
async def browser_grant(room_name: str, identity: str) -> dict:
async with CloudClient() as cloud:
grant = await cloud.create_token(room_name, identity, ttl="5m")
return grant.client_fields()

Return those fields from your token route. The browser uses token, wsUrl and fallbackUrls to connect to a room. Each participant needs a distinct identity and grant.

To try a call, run the FastAPI example locally. These commands assume you have Git and npm and have activated your Python environment.

git clone https://github.com/dTelecom/server-sdk-python.git
cd server-sdk-python/examples/fastapi
python -m pip install dtelecom-server-sdk fastapi uvicorn
npm ci
export DTELECOM_EXAMPLE_ROOM=voice-demo
uvicorn app:app --host 127.0.0.1

Open http://127.0.0.1:8000 in two tabs and select Join to make a browser-to-browser call. To talk to a Python agent, keep one browser in the room and run one of the examples below.

Use the RTC SDK when your process needs to exchange media. A participant can receive decoded mono PCM, publish microphone or synthesized audio, and send or receive room data. Pass the complete list of ranked node URLs when connecting.

from dtelecom_rtc import Room
async def participate(grant, finished):
async with Room() as room:
await room.connect(grant.ws_url, grant.token, fallback_urls=grant.fallback_urls)
await finished.wait()

Here grant is a token issued for this participant and finished is an asyncio.Event controlled by your application. The RTC example shows how to subscribe to a track and publish audio.

In a new terminal, activate the same Python environment and set the same three Cloud variables. The examples use dTelecom for speech and OpenRouter for the LLM. Set OPENROUTER_API_KEY for the model provider. Use the same room name as the browser issuer.

git clone https://github.com/dTelecom/agents-python.git
cd agents-python
python -m pip install 'dtelecom-agents[llm]'
python agents/examples/voice_agent.py voice-demo

Speak into the browser microphone. The agent greets you and answers through the room. Stop this agent before starting the Pipecat example in the same room.

For Pipecat, run these commands from the same agents-python checkout:

python -m pip install 'dtelecom-pipecat[rtc]' 'pipecat-ai[openrouter]>=1.17,<1.18'
ROOM_NAME=voice-demo python pipecat/examples/room_agent.py

The pipeline uses DTelecomTransport for room input and output, DTelecomSTTService for recognition, and DTelecomTTSService for speech. To use speech with a different transport, install the base dtelecom-pipecat package and supply your speech credentials. Pipecat adapters