LiteLLM adapter for Sefia.
Project description
sefia-litellm
A sefia LLMClient implementation that
connects to various LLM providers via
LiteLLM.
Install
pip install sefia-litellm
Or through the stack: pip install 'sefios[litellm]'.
Usage
import sefia_litellm
client = sefia_litellm.LiteLLMClient(model="gpt-4o")
Suppressing LiteLLM logging
LiteLLM logs through the standard-library LiteLLM logger — mostly INFO-level
messages that become visible whenever your application configures logging at
INFO/DEBUG — and, when a request raises, prints debug info including a
Provider List: ... banner. LiteLLMClient silences all of this by default.
Real failures still surface: LiteLLM raises exceptions on errors (which this
client maps to sefia exceptions), so silencing the logs never hides a failure.
There are two ways to control this:
-
Constructor argument
suppress_logs(takes precedence)# Suppress logs (default) client = sefia_litellm.LiteLLMClient(model="gpt-4o") client = sefia_litellm.LiteLLMClient(model="gpt-4o", suppress_logs=True) # Let LiteLLM log as usual client = sefia_litellm.LiteLLMClient(model="gpt-4o", suppress_logs=False)
-
Environment variable
SEFIA_LITELLM_SUPPRESS_LOGS(used as the default whensuppress_logsisNone)# Disable suppression (let logs through). 0/false/no/off disable it. export SEFIA_LITELLM_SUPPRESS_LOGS=false
An explicit
suppress_logsargument overrides the environment variable. When unset, suppression is on.
When suppression is on, the LiteLLM logger is fully silenced (its level is set
above CRITICAL) and litellm.suppress_debug_info is set to True. The logger
level is applied as soon as sefia_litellm is imported — before LiteLLM itself is
imported — so even LiteLLM's import-time warnings (e.g. optional-dependency
preload warnings) are suppressed.
On slow imports
Importing LiteLLM is heavy and can take around a second (see BerriAI/litellm#7605).
This package mitigates that as follows:
-
Lazy import — LiteLLM is imported only inside the methods that actually send a request. Importing
sefia_litellmalone costs nothing. After the first request the module is cached insys.modules, so subsequent imports are effectively free. This is the primary mitigation. -
Local model cost map —
LITELLM_LOCAL_MODEL_COST_MAP=Trueis set before LiteLLM is imported so that it uses its bundled cost map JSON instead of fetching it over the network. This speeds up the import and keeps it working offline.If you need up-to-date pricing for the newest models and the bundled map is stale, you can restore the original behavior:
export LITELLM_LOCAL_MODEL_COST_MAP=False
-
(Optional) Warm up at startup — if you also want to hide the first request's latency, import LiteLLM in the background during application startup. A daemon thread works regardless of whether an asyncio event loop is running yet:
import threading threading.Thread(target=__import__, args=("litellm",), daemon=True).start()
Status
Early development. APIs may change before v1.0.
License
MIT
Project details
Release history Release notifications | RSS feed
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 sefia_litellm-0.1.1.tar.gz.
File metadata
- Download URL: sefia_litellm-0.1.1.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf000214f1633de2c116f770e5647f0aa584453abba3be352367e945f02946ea
|
|
| MD5 |
1c3251ccf14c73c6885308aa8bb8cf00
|
|
| BLAKE2b-256 |
2fa64c47f7122d26ab4abb68df7bebcf0a809661d1c678047055f637a91a0b85
|
Provenance
The following attestation bundles were made for sefia_litellm-0.1.1.tar.gz:
Publisher:
publish-sefia-litellm.yml on nueruyu/sefia
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sefia_litellm-0.1.1.tar.gz -
Subject digest:
bf000214f1633de2c116f770e5647f0aa584453abba3be352367e945f02946ea - Sigstore transparency entry: 2198810459
- Sigstore integration time:
-
Permalink:
nueruyu/sefia@9865946087fcd813c49ee7503b83c96fefe9bd99 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nueruyu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sefia-litellm.yml@9865946087fcd813c49ee7503b83c96fefe9bd99 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sefia_litellm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: sefia_litellm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1c2decfaeec205baaa2da9d961f75536afdaf28f31b87aba5222baf31de4a73
|
|
| MD5 |
8dd87f251ee2f050a45c64b6263da219
|
|
| BLAKE2b-256 |
2ba1c3ef9d037b8faab589896ebc20e19b02df16c948e426d3c05134af874719
|
Provenance
The following attestation bundles were made for sefia_litellm-0.1.1-py3-none-any.whl:
Publisher:
publish-sefia-litellm.yml on nueruyu/sefia
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sefia_litellm-0.1.1-py3-none-any.whl -
Subject digest:
a1c2decfaeec205baaa2da9d961f75536afdaf28f31b87aba5222baf31de4a73 - Sigstore transparency entry: 2198810521
- Sigstore integration time:
-
Permalink:
nueruyu/sefia@9865946087fcd813c49ee7503b83c96fefe9bd99 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/nueruyu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-sefia-litellm.yml@9865946087fcd813c49ee7503b83c96fefe9bd99 -
Trigger Event:
push
-
Statement type: