Feat/add litellm provider - #913
Open
RheagalFire wants to merge 2 commits 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.
What type of PR is this?
feat, tests
Check the PR title.
(Optional) Translate the PR title into Chinese.
(Optional) More detailed description for this PR(en: English/zh: Chinese).
Summary
Adds a new
components/model/litellmChatModel provider that connects to a LiteLLM proxy, giving Eino users access to 100+ LLM providers (OpenAI, Anthropic, Google Gemini, AWS Bedrock, Azure OpenAI, Mistral, Cohere, and more) through a single component.LiteLLM is an open-source AI gateway where users configure all their models and API keys on the proxy server. A single LiteLLM ChatModel component lets Eino users reach any of these providers without waiting for individual provider modules to be added upstream.
Changes
components/model/litellm/chatmodel.go- NewChatModelwrappinglibs/acl/openaiwith LiteLLM proxy configcomponents/model/litellm/option.go- Per-request options (WithExtraFields,WithExtraHeader)components/model/litellm/chatmodel_test.go- Unit tests (10 test cases covering Generate, Stream, BindTools, WithTools, error propagation)components/model/litellm/go.mod- Independent Go modulecomponents/model/litellm/README.md- Documentation with usage examplescomponents/model/litellm/examples/- Generate and stream examplesArchitecture
The provider follows (same as
openrouter,openai): a thin wrapper aroundlibs/acl/openai.Client. LiteLLM proxy normalizes all provider responses to OpenAI format server-side, so no customRequestPayloadModifierorResponseMessageModifieris needed. This keeps the implementation minimal and maintainable.LiteLLM-specific features (metadata, tags, drop_params, force_timeout) are passed via the existing
ExtraFieldsconfig.Tests
Unit tests (all passing):
gofmt: Clean.
Risk / Compatibility
go.modfiles.libs/acl/openaiclient for all HTTP, streaming, and tool-calling logic.Example usage
1. Start a LiteLLM proxy (manages models + API keys server-side):
pip install litellm litellm --model openai/gpt-4o --model anthropic/claude-sonnet-4-20250514 # Proxy running at http://localhost:40002. Connect Eino to the proxy:
3. Streaming:
4. Tool calling:
5. Pass LiteLLM-specific parameters via ExtraFields:
zh(optional):
(Optional) Which issue(s) this PR fixes:
(optional) The PR that updates user documentation: