feat: add LiteLLM as LLM provider#833
Open
RheagalFire wants to merge 2 commits into
Open
Conversation
Author
Author
|
@eracle do you have any update on this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[## Summary
Adds LiteLLM as a new LLM provider option, enabling access to 100+ LLM backends (OpenAI, Anthropic, Google, Azure, AWS Bedrock, Ollama, etc.) through a single LiteLLM proxy server.
LiteLLM appears as a selectable "LiteLLM" option in the Django admin provider dropdown alongside the existing providers.
How it works
LiteLLM runs as an OpenAI-compatible proxy, so the implementation reuses
pydantic-ai's existingOpenAIModel/OpenAIProviderwith a custombase_urlpointing at the LiteLLM proxy. No new dependencies are required.Configuration (Django admin
SiteConfig):http://localhost:4000/v1)anthropic/claude-sonnet-4-20250514)Changes
linkedin/llm.py_build_litellm()builder + registration in_PROVIDER_BUILDERS+ API key validation skip for litellmlinkedin/models.pyLITELLM = "litellm", "LiteLLM"added toSiteConfig.LLMProviderchoiceslinkedin/migrations/0008_...llm_providerfieldtests/test_litellm_provider.pyTesting
Unit tests (11 passing):
OpenAIModelwith correct model namellm_api_baseis required (raisesValueErrorif empty)_validated_site_config()skips API key check for litellm_validated_site_config()still requiresai_modelget_llm_model()works for both local and hosted scenariosFull test suite: 240 passed, 0 failures.
Manual testing against LiteLLM proxy (
http://localhost:4000/v1) routing to Anthropic:The builder follows the same
AsyncOpenAI+OpenAIModel+OpenAIProviderpattern used by the existingopenai_compatibleprovider, so streaming, tool calling, and structured output all work through the proxy.](http://localhost:8000/admin/)