Skip to main content

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")

Provider compatibility

The opt-in live compatibility suite covers OpenAI, Anthropic, Gemini, xAI, Mistral, Groq, DeepSeek, and local Ollama. Each provider is skipped unless its enabling environment variable is set; suite coverage does not imply that every provider was exercised in a given test run. See the provider table in CONTRIBUTING.md.

See the live-provider table and opt-in test command in the repository's CONTRIBUTING.md.

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 when suppress_logs is None)

    # Disable suppression (let logs through). 0/false/no/off disable it.
    export SEFIA_LITELLM_SUPPRESS_LOGS=false
    

    An explicit suppress_logs argument 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:

  1. Lazy import — LiteLLM is imported only inside the methods that actually send a request. Importing sefia_litellm alone costs nothing. After the first request the module is cached in sys.modules, so subsequent imports are effectively free. This is the primary mitigation.

  2. Local model cost mapLITELLM_LOCAL_MODEL_COST_MAP=True is 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
    
  3. (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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sefia_litellm-0.4.0.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sefia_litellm-0.4.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file sefia_litellm-0.4.0.tar.gz.

File metadata

  • Download URL: sefia_litellm-0.4.0.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sefia_litellm-0.4.0.tar.gz
Algorithm Hash digest
SHA256 21c7beaa00956611a62b1dab1d8e57c8f596e77297de136630cef9651d63a779
MD5 faa9820c20ae1882548fc61d6633f3f0
BLAKE2b-256 83c51875fca1e5f7a305d1c760f04f7124ec4c7bdd446b8c71bf2dc5dfbd65ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for sefia_litellm-0.4.0.tar.gz:

Publisher: publish-sefia-litellm.yml on nueruyu/sefia

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sefia_litellm-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: sefia_litellm-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sefia_litellm-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 257e98254051d8dffdedd61bec2533311bf024a731abf55e6fcbf08f0aeaa1c7
MD5 e8cff61e880dac5a5c74b3d3bfd953aa
BLAKE2b-256 410ba0b7f7c0b92c27ae62c10eef522317c93f78bef5e003b09f8d9f856685cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for sefia_litellm-0.4.0-py3-none-any.whl:

Publisher: publish-sefia-litellm.yml on nueruyu/sefia

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page