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.1.tar.gz (18.1 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.1-py3-none-any.whl (22.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: centralized_llm_client-0.1.1.tar.gz
  • Upload date:
  • Size: 18.1 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.1.tar.gz
Algorithm Hash digest
SHA256 fa5042abe0b35d6f26bba7a541ed9c4a1dd9a74a174df767fa29a43976d0d774
MD5 fb5a286d23af768aa360a5e23d861597
BLAKE2b-256 0c95a7f7b28692087a8af9e871e5a6a51d752ea0ca6c123c56f6d318ac9d1cf4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for centralized_llm_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4e5754d51345537c6130b28533ec14c4800d4b9b2c53dd5b6632695d09cc117
MD5 a35069c402d757107900f51be195a1a8
BLAKE2b-256 91303f5b5e70335da160f49b7a656c652fb69759008d0af8264ddd07c6233606

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