Skip to main content

Architecture

Vaani uses a factory pattern to abstract AI providers. Each provider type has a factory class that creates the appropriate SDK instance based on the agent’s configuration.

Adding a New TTS Provider (Example)

1

Install the LiveKit Plugin

cd agent-studio-livekit-agent
pip install livekit-plugins-newprovider
Add to requirements.txt:
livekit-plugins-newprovider==1.0.0
2

Update the Factory

Edit agent-studio-livekit-agent/plugins/tts.py:
from livekit.plugins import newprovider as newprovider_tts  # Add import

class TTSFactory:
    @staticmethod
    def get_instance(agent_config):
        provider = agent_config.get("TTS_provider", "").lower()
        
        # ... existing providers ...
        
        elif provider == "newprovider":
            return newprovider_tts.TTS(
                api_key=settings.NEWPROVIDER_API_KEY,
                model=agent_config.get("TTS_model", "default-model"),
                voice=agent_config.get("TTS_voice", "default-voice"),
            )
3

Add Configuration

Add the API key to your environment:agent-studio-livekit-agent/.env:
NEWPROVIDER_API_KEY=your_api_key_here
config.py or relevant settings file:
NEWPROVIDER_API_KEY = os.getenv("NEWPROVIDER_API_KEY")
4

Update Agent Model (Optional)

If the provider needs new config fields, update:
  • app/db/models/agent.py — add columns
  • app/db/schemas/agent.py — add Pydantic fields
  • Run alembic revision --autogenerate -m "add newprovider fields"
  • Run alembic upgrade head
5

Update UI Dropdowns

Add the new provider to the agent creation/edit form dropdowns in the Next.js dashboard.

Provider Pattern Reference

File: plugins/llm.pyLLMFactory
ProviderSDKMethod
OpenAIlivekit-plugins-openaiget_instance()
Groqlivekit-plugins-groqget_instance()
Also handles: get_turn_detection() for VAD configuration.
The factory pattern means adding a new provider requires changes in exactly one file (the factory) plus environment configuration. No architectural changes needed.