Skip to main content

Unified Python client for multiple LLM providers with fallback, file handling, and logging.

Project description

Centralized-LLM-Client

Unified Python client for interacting with multiple LLM providers (OpenAI, Gemini, OpenRouter) with automatic fallback, secure key management, file handling, and MongoDB logging.

Features

  • Automatic provider fallback (OpenAI, Gemini, OpenRouter)
  • Secure API key management (encrypted, MongoDB Atlas)
  • File handling: supports local, S3, and FastAPI UploadFile
  • Detailed logging of all LLM calls to MongoDB Atlas
  • S3 integration for file storage/retrieval

Installation

Python 3.9+ required.

pip install Centralized-LLM-Client
# Or, for local development:
pip install -r src/requirements.txt

Quickstart

from src.CentralizedClient import CentralizedLLMClient
client = CentralizedLLMClient(username="alice")
response = await client.completion("Summarize this document.")

Architecture

  • src/CentralizedClient/CentralizedLLMClient.py: Main orchestration, provider fallback logic
  • Providers: gemini_provider.py, openai_provider.py, openrouter_provider.py (wrap LLM APIs)
  • Key Management: key_manager.py (encrypted keys, user/system fallback)
  • File Handling: file_processor.py (temp files, S3/local/FastAPI)
  • Logging: llm_logger.py (MongoDB Atlas logging)
  • External Integrations: S3 (utils/s3_file_manager.py), MongoDB Atlas (utils/atlas_client.py)

Environment Setup

  • Set environment variables for S3, MongoDB Atlas, and LLM provider keys (see .env usage in utils)
  • Place key.bin (encryption key) in project root for key decryption

Testing

  • Add tests in tests/ and run with pytest:
     pytest tests/
    

Contributing

Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.

License

MIT License

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

centralized_llm_client-0.1.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

centralized_llm_client-0.1.0-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file centralized_llm_client-0.1.0.tar.gz.

File metadata

  • Download URL: centralized_llm_client-0.1.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for centralized_llm_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7dbf9226ebe3127e6d8f514301f3f36480d2346bd7d9c43c566b130f2d20ef41
MD5 0442fe30520face41acacebf91aef506
BLAKE2b-256 6bb2f6cf5bc6b5acc4933468f079a834a2620f292e2fa49c035a0d1e0efd50d0

See more details on using hashes here.

File details

Details for the file centralized_llm_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for centralized_llm_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa80cb8b3047f7f19553e1ed3b0f7a75f851afe2022e8675870b6b934e56f594
MD5 5bec63f1b561d0065822d1ababf1f44a
BLAKE2b-256 75c7330ab57ae914bc830e9e756b9527b456edd29e22e4351d79a39031225a74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page