Skip to content

feat: add LiteLLM as an LLM provider - #130

Open
RheagalFire wants to merge 1 commit into
datascale-ai:mainfrom
RheagalFire:feat/add-litellm-provider
Open

feat: add LiteLLM as an LLM provider#130
RheagalFire wants to merge 1 commit into
datascale-ai:mainfrom
RheagalFire:feat/add-litellm-provider

Conversation

@RheagalFire

Copy link
Copy Markdown

Summary

Add LiteLLM as an LLM provider, giving OpenTalking access to 100+ LLM providers (OpenAI, Anthropic, Google, Bedrock, Azure, Ollama, etc.) through a single interface.

Set OPENTALKING_LLM_PROVIDER=litellm and use LiteLLM model format in OPENTALKING_LLM_MODEL:

# Anthropic Claude
export OPENTALKING_LLM_PROVIDER=litellm
export OPENTALKING_LLM_MODEL=anthropic/claude-sonnet-4-6
export ANTHROPIC_API_KEY=sk-ant-...

# Google Gemini
export OPENTALKING_LLM_PROVIDER=litellm
export OPENTALKING_LLM_MODEL=gemini/gemini-pro
export GEMINI_API_KEY=...

# LiteLLM proxy
export OPENTALKING_LLM_PROVIDER=litellm
export OPENTALKING_LLM_BASE_URL=http://localhost:4000
export OPENTALKING_LLM_API_KEY=sk-proxy-key
export OPENTALKING_LLM_MODEL=gpt-4o

Changes:

  • New opentalking/providers/llm/litellm_chat/ provider with LiteLLMChatClient implementing chat_stream() via litellm.acompletion(stream=True, drop_params=True)
  • New opentalking/providers/llm/factory.py with create_llm_client() factory dispatching on llm_provider config
  • Updated all 5 LLM client instantiation sites to use the factory
  • Optional dep: pip install opentalking[litellm]
  • 6 unit tests

Backward compatible - defaults to openai_compatible when OPENTALKING_LLM_PROVIDER is unset.

from opentalking.providers.llm.litellm_chat.adapter import LiteLLMChatClient

client = LiteLLMChatClient(
    base_url="",  # optional - only needed for proxy
    api_key="sk-...",
    model="anthropic/claude-sonnet-4-6",
)
async for chunk in client.chat_stream(messages):
    print(chunk, end="")

Validation

  • ruff check src/opentalking/core src/opentalking/server src/opentalking/worker src/opentalking/llm src/opentalking/tts src/opentalking/avatars src/opentalking/events src/opentalking/rtc apps/api apps/unified apps/cli tests
  • mypy src/opentalking/core src/opentalking/server src/opentalking/worker src/opentalking/llm src/opentalking/tts src/opentalking/avatars src/opentalking/events src/opentalking/rtc apps/api apps/unified apps/cli --ignore-missing-imports
  • pytest apps/api/tests apps/worker/tests tests
  • cd apps/web && npm run build

Notes

  • litellm is an optional dependency (pip install opentalking[litellm]) - no impact on existing installations
  • LiteLLM provider does not require OPENTALKING_LLM_BASE_URL (unlike openai_compatible), since LiteLLM routes via the model identifier prefix (e.g. anthropic/claude-sonnet-4-6)
  • drop_params=True enabled by default to handle per-provider parameter differences

Add LiteLLM AI gateway integration supporting 100+ LLM providers
through a single interface. Users can switch by setting
OPENTALKING_LLM_PROVIDER=litellm.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant