feat: add LiteLLM as AI gateway provider#1295
Open
RheagalFire wants to merge 1 commit into
Open
Conversation
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
ClaudeModel). Drop-in, no changes to existing providers.Motivation
llmware currently supports individual API providers (OpenAI, Claude, Google Gemini) each as separate model classes. LiteLLM is a lightweight Python SDK that provides a unified
completion()interface across 100+ providers. Users specify the provider via the model string (e.g.anthropic/claude-sonnet-4-5,bedrock/anthropic.claude-v2,vertex_ai/gemini-pro) and LiteLLM routes the call to the correct provider API. This lets users access any LiteLLM-supported provider without needing a new model class for each one.Changes
llmware/models.py- newLiteLLMModelclass extendingBaseModel, registered in_ModelRegistry.model_classessetup.py- addedlitellm>=1.55.0,<1.85as optional dependency (pip install llmware[litellm])Implementation details
litellmis lazy-imported insideinference()andstream(), following the same pattern asClaudeModel(which importsanthropicinside its methods). Users who don't install litellm are unaffected.drop_params=True: Silently drops provider-unsupported kwargs, preventing cross-provider failures.stream()method implemented as a generator matching theClaudeModel.stream()pattern.ANTHROPIC_API_KEY,OPENAI_API_KEY,GEMINI_API_KEY, etc.).prompt_engineer()pattern fromClaudeModel.Example usage
Or use via
ModelCatalogby registering a model card:Tests
Live E2E test against Anthropic Claude (
anthropic/claude-sonnet-4-5):Risk / Compatibility
litellmis an optional extra. Base install unaffected.>=1.55.0,<1.85for stability.