# exotel/agent-stream architecture

> Architecture diagram of the GitHub repository exotel/agent-stream, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/exotel/agent-stream
- Repository: https://github.com/exotel/agent-stream

## Overview

Agent-Stream is a collection of Exotel AgentStream voice bridges, from provider-specific realtime integrations to composable STT/LLM/TTS recipes and a Dograh telephony adapter. The principal workflow is to start a bridge, have Exotel connect a call’s bidirectional audio stream, process it through the selected voice stack, and return audio to the caller. The README documents the integration choices and call setup; sampled source confirms several bridge-to-provider and shared-session paths. Other unsampled integrations are represented at their documented directory level.

Main entry points: [`integrations/agents`](https://github.com/exotel/agent-stream/tree/main/integrations/agents) (Voice stack recipes), [`integrations/sarvam/server.py`](https://github.com/exotel/agent-stream/blob/main/integrations/sarvam/server.py) (Sarvam pipeline bridge), [`integrations/dograh/providers/exotel`](https://github.com/exotel/agent-stream/tree/main/integrations/dograh/providers/exotel) (Dograh Exotel adapter), [`integrations/agents/_shared/wss_server.py`](https://github.com/exotel/agent-stream/blob/main/integrations/agents/_shared/wss_server.py) (Recipe WebSocket host)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_call["Call setup"]
  node_connect_api["Connect Voice AI API"]
  node_call_script["Call placer"]
end

subgraph group_realtime["Realtime bridges"]
  node_openai["OpenAI Realtime bridge<br/>[bot.py]"]
  node_gemini["Gemini Live bridge<br/>[server.js]"]
  node_elevenlabs["ElevenLabs bridge<br/>[bridge.py]"]
end

subgraph group_recipes["Agent recipes"]
  node_sarvam["Sarvam pipeline bridge<br/>[server.py]"]
  node_sarvam_services["Sarvam STT/TTS"]
  node_pipecat["Pipecat bridge<br/>[server.py]"]
  node_pipecat_bot["Pipecat voice bot<br/>[bot.py]"]
  node_recipe_stacks["Voice stack recipes"]
end

subgraph group_platform["Platform adapters"]
  node_dograh["Dograh Exotel adapter"]
  node_dograh_provider["Provider integration<br/>[provider.py]"]
  node_dograh_transport["WebSocket transport<br/>[transport.py]"]
end

subgraph group_shared["Shared runtime"]
  node_agent_host["Recipe WebSocket host<br/>[wss_server.py]"]
  node_pipeline_session["Turn pipeline session<br/>[pipeline_agent.py]"]
  node_agent_shared_providers["Recipe providers<br/>[providers.py]"]
  node_agent_shared_media["Audio media helpers<br/>[media.py]"]
end

node_caller(("Caller"))
node_exotel["Exotel AgentStream"]

node_caller -->|"places call"| node_exotel
node_call_script -->|"requests call"| node_connect_api
node_connect_api -->|"starts call"| node_exotel
node_exotel -->|"streams audio"| node_openai
node_openai -->|"returns audio"| node_exotel
node_exotel -->|"streams audio"| node_gemini
node_gemini -->|"returns audio"| node_exotel
node_exotel -->|"streams audio"| node_elevenlabs
node_elevenlabs -->|"returns audio"| node_exotel
node_exotel -->|"streams audio"| node_sarvam
node_sarvam -->|"returns audio"| node_exotel
node_sarvam -->|"calls STT/TTS"| node_sarvam_services
node_exotel -->|"streams audio"| node_pipecat
node_pipecat -->|"runs bot"| node_pipecat_bot
node_exotel -->|"opens WebSocket"| node_agent_host
node_agent_host -.->|"creates session"| node_pipeline_session
node_pipeline_session -.->|"uses audio helpers"| node_agent_shared_media
node_recipe_stacks -->|"uses shared host"| node_agent_host
node_recipe_stacks -->|"uses turn pipeline"| node_pipeline_session
node_recipe_stacks -->|"uses provider adapters"| node_agent_shared_providers
node_exotel -->|"telephony integration"| node_dograh
node_dograh -->|"provides integration"| node_dograh_provider
node_dograh -->|"uses transport"| node_dograh_transport

click node_call_script "https://github.com/exotel/agent-stream/blob/main/shared/place_connect_call.py"
click node_openai "https://github.com/exotel/agent-stream/blob/main/integrations/openai-realtime/core/bot.py"
click node_gemini "https://github.com/exotel/agent-stream/blob/main/integrations/gemini-live/server.js"
click node_elevenlabs "https://github.com/exotel/agent-stream/blob/main/integrations/elevenlabs/exotel/bridge.py"
click node_sarvam "https://github.com/exotel/agent-stream/blob/main/integrations/sarvam/server.py"
click node_sarvam_services "https://github.com/exotel/agent-stream/blob/main/integrations/sarvam/sarvam_agentstream_pipeline.py"
click node_pipecat "https://github.com/exotel/agent-stream/blob/main/integrations/pipecat/server.py"
click node_pipecat_bot "https://github.com/exotel/agent-stream/blob/main/integrations/pipecat/bot.py"
click node_agent_host "https://github.com/exotel/agent-stream/blob/main/integrations/agents/_shared/wss_server.py"
click node_pipeline_session "https://github.com/exotel/agent-stream/blob/main/integrations/agents/_shared/pipeline_agent.py"
click node_agent_shared_providers "https://github.com/exotel/agent-stream/blob/main/integrations/agents/_shared/providers.py"
click node_agent_shared_media "https://github.com/exotel/agent-stream/blob/main/integrations/agents/_shared/media.py"
click node_recipe_stacks "https://github.com/exotel/agent-stream/tree/main/integrations/agents"
click node_dograh "https://github.com/exotel/agent-stream/tree/main/integrations/dograh/providers/exotel"
click node_dograh_provider "https://github.com/exotel/agent-stream/blob/main/integrations/dograh/providers/exotel/provider.py"
click node_dograh_transport "https://github.com/exotel/agent-stream/blob/main/integrations/dograh/providers/exotel/transport.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_connect_api,node_call_script toneBlue
class node_openai,node_gemini,node_elevenlabs toneAmber
class node_sarvam,node_sarvam_services,node_pipecat,node_pipecat_bot,node_recipe_stacks toneMint
class node_dograh,node_dograh_provider,node_dograh_transport toneRose
class node_agent_host,node_pipeline_session,node_agent_shared_providers,node_agent_shared_media,node_caller,node_exotel toneIndigo
```

## Components

### Call setup

- **Connect Voice AI API**
- [Call placer](https://github.com/exotel/agent-stream/blob/main/shared/place_connect_call.py): `shared/place_connect_call.py`

### Realtime bridges

- [OpenAI Realtime bridge](https://github.com/exotel/agent-stream/blob/main/integrations/openai-realtime/core/bot.py): `integrations/openai-realtime/core/bot.py`
- [Gemini Live bridge](https://github.com/exotel/agent-stream/blob/main/integrations/gemini-live/server.js): `integrations/gemini-live/server.js`
- [ElevenLabs bridge](https://github.com/exotel/agent-stream/blob/main/integrations/elevenlabs/exotel/bridge.py): `integrations/elevenlabs/exotel/bridge.py`

### Agent recipes

- [Sarvam pipeline bridge](https://github.com/exotel/agent-stream/blob/main/integrations/sarvam/server.py): `integrations/sarvam/server.py`
- [Sarvam STT/TTS](https://github.com/exotel/agent-stream/blob/main/integrations/sarvam/sarvam_agentstream_pipeline.py): `integrations/sarvam/sarvam_agentstream_pipeline.py`
- [Pipecat bridge](https://github.com/exotel/agent-stream/blob/main/integrations/pipecat/server.py): `integrations/pipecat/server.py`
- [Pipecat voice bot](https://github.com/exotel/agent-stream/blob/main/integrations/pipecat/bot.py): `integrations/pipecat/bot.py`
- [Voice stack recipes](https://github.com/exotel/agent-stream/tree/main/integrations/agents): `integrations/agents`

### Platform adapters

- [Dograh Exotel adapter](https://github.com/exotel/agent-stream/tree/main/integrations/dograh/providers/exotel): `integrations/dograh/providers/exotel`
- [Provider integration](https://github.com/exotel/agent-stream/blob/main/integrations/dograh/providers/exotel/provider.py): `integrations/dograh/providers/exotel/provider.py`
- [WebSocket transport](https://github.com/exotel/agent-stream/blob/main/integrations/dograh/providers/exotel/transport.py): `integrations/dograh/providers/exotel/transport.py`

### Shared runtime

- [Recipe WebSocket host](https://github.com/exotel/agent-stream/blob/main/integrations/agents/_shared/wss_server.py): `integrations/agents/_shared/wss_server.py`
- [Turn pipeline session](https://github.com/exotel/agent-stream/blob/main/integrations/agents/_shared/pipeline_agent.py): `integrations/agents/_shared/pipeline_agent.py`
- [Recipe providers](https://github.com/exotel/agent-stream/blob/main/integrations/agents/_shared/providers.py): `integrations/agents/_shared/providers.py`
- [Audio media helpers](https://github.com/exotel/agent-stream/blob/main/integrations/agents/_shared/media.py): `integrations/agents/_shared/media.py`

### Other components

- **Caller**
- **Exotel AgentStream**

## Connections

- Caller → Exotel AgentStream: places call
- Call placer → Connect Voice AI API: requests call
- Connect Voice AI API → Exotel AgentStream: starts call
- Exotel AgentStream → OpenAI Realtime bridge: streams audio
- OpenAI Realtime bridge → Exotel AgentStream: returns audio
- Exotel AgentStream → Gemini Live bridge: streams audio
- Gemini Live bridge → Exotel AgentStream: returns audio (evidence: `integrations/gemini-live/server.js`)
- Exotel AgentStream → ElevenLabs bridge: streams audio
- ElevenLabs bridge → Exotel AgentStream: returns audio
- Exotel AgentStream → Sarvam pipeline bridge: streams audio
- Sarvam pipeline bridge → Exotel AgentStream: returns audio (evidence: `integrations/sarvam/server.py`)
- Sarvam pipeline bridge → Sarvam STT/TTS: calls STT/TTS (evidence: `integrations/sarvam/server.py`)
- Exotel AgentStream → Pipecat bridge: streams audio
- Pipecat bridge → Pipecat voice bot: runs bot (evidence: `integrations/pipecat/server.py`)
- Exotel AgentStream → Recipe WebSocket host: opens WebSocket (evidence: `integrations/agents/_shared/wss_server.py`)
- Recipe WebSocket host → Turn pipeline session: creates session (evidence: `integrations/agents/_shared/pipeline_agent.py`)
- Turn pipeline session → Audio media helpers: uses audio helpers
- Voice stack recipes → Recipe WebSocket host: uses shared host (evidence: `integrations/agents/cartesia-line-native/server.py`)
- Voice stack recipes → Turn pipeline session: uses turn pipeline (evidence: `integrations/sarvam/server.py`)
- Voice stack recipes → Recipe providers: uses provider adapters (evidence: `integrations/agents/speechmatics-gpt-elevenlabs-native/agent.py`)
- Exotel AgentStream → Dograh Exotel adapter: telephony integration
- Dograh Exotel adapter → Provider integration: provides integration (evidence: `integrations/dograh/providers/exotel/__init__.py`)
- Dograh Exotel adapter → WebSocket transport: uses transport (evidence: `integrations/dograh/providers/exotel/__init__.py`)
