Unified LLM client. Currently supports Openai, Azure Openai and Google Gemini
Project description
llm-client
ehs-llm-client is a unified async Python client for interacting with multiple LLM providers, including OpenAI, Azure OpenAI, and Google Gemini.
It supports single calls, structured JSON outputs, and batch processing, designed for production-ready, reusable code in applications, scripts, or pipelines.
Features
- Async support for multiple LLM providers
- Unified interface across OpenAI, Azure, and Google Gemini
- Structured JSON responses via schemas
- Retry and timeout handling
- Batch processing support
- Environment variable configuration for API keys
- Easy integration into existing projects or monorepos
Installation
# Install from PyPI
pip install ehs-llm-client
Or install editable version during development:
# From project root
pip install -e .
Configuration
ehs-llm-client supports three configuration modes:
1️⃣ Config file (.cfg)
Example: llmconfig.cfg
[default_settings]
provider = openai
model = gpt-4.1-mini
[prod]
provider = openai
model = gpt-4.1
model_batch = gpt-4.1-mini
Usage:
from ehs_llm_client import LLM
llm = LLM("prod", config_file_path="llmconfig.cfg")
2️⃣ Config dictionary (for tests / CI)
from ehs_llm_client import LLM
llm = LLM(
"default",
config={
"default_settings": {
"provider": "openai",
"model": "gpt-4.1-mini"
}
}
)
3️⃣ Environment variable fallback
export LLM_PROVIDER=openai
export LLM_MODEL=gpt-4.1-mini
export OPENAI_API_KEY=sk-...
llm = LLM("default")
Usage
Single async call
import asyncio
from ehs_llm_client import LLM
async def main():
llm = LLM("prod")
messages = [{"role": "user", "content": "Say hello in JSON"}]
response, in_tokens, out_tokens = await llm.get_response_async(
messages, schema="return json"
)
print(response)
asyncio.run(main())
Batch request
batch_line = llm.create_batch_request(
custom_id="test1",
messages=[{"role": "user", "content": "Give me a JSON object"}],
schema="return json"
)
batch_id = await llm.run_batch_process([batch_line], submission_id="batch123")
status = await llm.get_batch_status(batch_id)
print(status)
API Key Management
Keep API keys out of code. Recommended environment variables:
| Provider | Env var name |
|---|---|
| OpenAI | openaiAPIkey |
| Azure OpenAI | azure_openaiAPIkey |
| Google Gemini | googleAPIkey |
Development
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windows
# Install dependencies
pip install -e .
License
MIT License © 2026 Your Name
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 ehs_llm_client-0.1.10.tar.gz.
File metadata
- Download URL: ehs_llm_client-0.1.10.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
459f75e36d01147dfd41fa8b57c7b22833d6f09dd73e0669461e19f4199f0446
|
|
| MD5 |
d71cd391cfa81f13750ce3338e7fa292
|
|
| BLAKE2b-256 |
f3d9431c953cc75ceafcacdda4532c87e08de13054b3c7f6cd7be9ed98ae364a
|
File details
Details for the file ehs_llm_client-0.1.10-py3-none-any.whl.
File metadata
- Download URL: ehs_llm_client-0.1.10-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11ba02f08a64b6790fa717d19dcedc8d29df520fed6c68fea48cd4afaf9e077d
|
|
| MD5 |
22d55332c8337dc951ce3361182fff6d
|
|
| BLAKE2b-256 |
799f83c59f54aed0c4e21d60d2f0303eef25458ad059a0d057b9ff5ebbb274b1
|