Lightweight litellm replacement — thin OpenAI-SDK routing layer for multi-provider LLM calls
Project description
litelm
litellm is bloated. 86 MB of dependencies for what is mostly a router.
litelm strips it to core routing + formatting. ~2,000 lines. Two deps (openai, httpx).
Strategy
litellm has become infrastructure — dozens of frameworks depend on it. We validate litelm as a drop-in replacement one consumer at a time, starting with the most popular.
Current target: DSPy — full drop-in verified. All 7 execution paths proven live (Predict, CoT, typed signatures, streaming, embeddings, tool use, multi-output). 6 providers tested.
Next targets: LangChain, CrewAI, AutoGen — litellm's most depended-on consumers. Each one we pass is proof the API surface is correct.
The litellm test suite itself runs against litelm unmodified via sys.modules shimming — 206 tests passing and climbing.
import litelm
response = litelm.completion("openai/gpt-4o", messages=[{"role": "user", "content": "Hello!"}])
response = litelm.completion("groq/llama-3.1-70b-versatile", messages=[...], stream=True)
response = litelm.embedding("openai/text-embedding-3-small", input=["hello world"])
Every function has an async variant: acompletion, aembedding, aresponses, atext_completion.
Drop-in usage (DSPy example)
import sys, litelm
sys.modules["litellm"] = litelm
import dspy # now uses litelm for all LLM calls
lm = dspy.LM("openai/gpt-4o-mini")
dspy.configure(lm=lm)
dspy.Predict("question -> answer")(question="What is 2+2?")
The sys.modules swap must happen before the consumer import.
Install
pip install litelm # openai + httpx
pip install litelm[anthropic] # + anthropic SDK
pip install litelm[bedrock] # + boto3
pip install litelm[all] # everything
Providers
"provider/model-name" → routes to the right base URL and API key.
OpenAI, Azure, Groq, Together, Fireworks, Mistral, DeepSeek, OpenRouter, Anthropic, Perplexity, xAI, Gemini, Cohere, Cloudflare, Bedrock, Ollama — and any OpenAI-compatible endpoint via api_base.
Custom handlers (non-OpenAI-compat): Anthropic, Bedrock, Cloudflare, Mistral.
What's Implemented
| Function | Status |
|---|---|
completion / acompletion |
Implemented |
embedding / aembedding |
Implemented |
responses / aresponses |
Implemented |
text_completion / atext_completion |
Implemented |
stream_chunk_builder |
Implemented |
mock_response |
Implemented |
supports_function_calling |
Stub (always True) |
supports_response_schema |
Stub (always True) |
supports_reasoning |
Implemented (pattern match) |
get_supported_openai_params |
Implemented |
What's Not Implemented (by design)
Proxy, router, caching, budgeting, agents, guardrails, image gen, audio, OCR, fine-tuning, batches, assistants, scheduler, token counting, cost tracking.
Tests
uv run pytest tests/ -x --ignore=tests/ported # 92 unit tests
uv run pytest tests/test_live.py -m live --timeout=30 # 37 live provider tests
uv run pytest tests/test_dspy_smoke.py -m live --timeout=60 # 10 DSPy integration tests
Live tests require API keys in .env.test. Skipped by default; run with -m live.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file litelm-0.1.0.tar.gz.
File metadata
- Download URL: litelm-0.1.0.tar.gz
- Upload date:
- Size: 237.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a04b5d8eacbf4065408cf04bd58ba40cbf24f2331dd1940ef582016cd8f1885f
|
|
| MD5 |
e8972e0c4088c0e354e0a84806d5d35d
|
|
| BLAKE2b-256 |
112435e65c8f20e289ae8d729d28f84b06e06534ca4a32b8d5f9f0bb09d38e4c
|
Provenance
The following attestation bundles were made for litelm-0.1.0.tar.gz:
Publisher:
publish.yml on kennethwolters/litelm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
litelm-0.1.0.tar.gz -
Subject digest:
a04b5d8eacbf4065408cf04bd58ba40cbf24f2331dd1940ef582016cd8f1885f - Sigstore transparency entry: 1097543854
- Sigstore integration time:
-
Permalink:
kennethwolters/litelm@a954b6d719c928a62e49d2c18bf22f9b2e8e6f08 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kennethwolters
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a954b6d719c928a62e49d2c18bf22f9b2e8e6f08 -
Trigger Event:
release
-
Statement type:
File details
Details for the file litelm-0.1.0-py3-none-any.whl.
File metadata
- Download URL: litelm-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc56c74ac0240c17f1f419dab4a17c911baefad56d670157f50dfd0cfafd1920
|
|
| MD5 |
3d3899dcf69cd61c357cd983857393b5
|
|
| BLAKE2b-256 |
b121df6805f73e946f8be452bcca60f0fde28264a84fb6c9cb13b1b0330b98af
|
Provenance
The following attestation bundles were made for litelm-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on kennethwolters/litelm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
litelm-0.1.0-py3-none-any.whl -
Subject digest:
bc56c74ac0240c17f1f419dab4a17c911baefad56d670157f50dfd0cfafd1920 - Sigstore transparency entry: 1097543918
- Sigstore integration time:
-
Permalink:
kennethwolters/litelm@a954b6d719c928a62e49d2c18bf22f9b2e8e6f08 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kennethwolters
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a954b6d719c928a62e49d2c18bf22f9b2e8e6f08 -
Trigger Event:
release
-
Statement type: