Universal LLM Connector
A Python SDK that provides a unified interface to all major LLM providers. Built on httpx for reliable HTTPS handling - system certificate support, custom base URLs, and async out of the box.
Problem Statement
Python developers face two recurring problems when working with LLM APIs:
1. No unified interface across providers. OpenAI, Anthropic, Google Gemini, Azure, AWS Bedrock, and others all have different request/response formats, auth methods, and endpoint patterns. Switching providers means rewriting integration code.
2. SSL certificate issues in managed environments. Python's HTTP libraries (requests, urllib3, httpx, aiohttp) use certifi - a static bundle of ~130 public CA certificates. If the OS trust store contains additional certificates, Python ignores them. Downloads, API calls through gateways, and pip installs from internal mirrors all fail with SSLError: certificate verify failed.
The existing solution (litellm) is built on requests (synchronous only, same SSL issues) and uses fragile model name decoding.
Solution
universal-llm-connector provides:
- A unified API for 10 LLM providers (sync + async, streaming, embeddings, tool calling, vision)
corporate_fix()- configures Python to use the OS certificate store instead of certifi's static bundleconfigure_huggingface()- patcheshuggingface_hubsotransformers,diffusers, andaccelerateuse system certificates
Installation
Works on Windows, macOS, and Linux. Requires Python 3.10+.
pip install universal-llm-connector
With optional extras:
pip install universal-llm-connector[socks] # SOCKS5 proxy support
pip install universal-llm-connector[bedrock] # AWS Bedrock (SigV4 signing)
pip install universal-llm-connector[huggingface] # HuggingFace Hub patching
pip install universal-llm-connector[all] # Everything
From source:
git clone https://github.com/rs2pydev/universal-llm-connector.git
cd universal-llm-connector
pip install -e ".[dev]"
Quick Start
Basic completion
from universal_llm_connector import completion
response = completion(
model="openai/gpt-4o",
api_key="sk-...",
messages=[{"role": "user", "content": "What is the capital of France?"}],
)
print(response.content)
Custom base URL (API gateways, self-hosted endpoints)
response = completion(
model="openai/gpt-4o",
base_url="https://your-gateway.example.com/v1",
api_key="your-token",
use_system_certs=True,
messages=[{"role": "user", "content": "Hello!"}],
)
OpenAI Responses API
response = completion(
model="openai/gpt-4o",
api="responses",
api_key="sk-...",
input="Explain quantum computing in one sentence.",
instructions="Be concise.",
)
Async
import asyncio
from universal_llm_connector import acompletion
async def main():
response = await acompletion(
model="openai/gpt-4o",
api_key="sk-...",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.content)
asyncio.run(main())
Streaming
from universal_llm_connector import completion
for chunk in completion(
model="openai/gpt-4o",
api_key="sk-...",
messages=[{"role": "user", "content": "Write a haiku."}],
stream=True,
):
print(chunk.content, end="", flush=True)
Embeddings
from universal_llm_connector import embed
response = embed(
model="openai/text-embedding-3-small",
input=["First sentence", "Second sentence"],
api_key="sk-...",
)
vectors = response.embeddings
Tool calling
from universal_llm_connector import completion
from universal_llm_connector.models.messages import Tool, FunctionDef
weather_tool = Tool(
function=FunctionDef(
name="get_weather",
description="Get weather for a city",
parameters={
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
)
)
response = completion(
model="openai/gpt-4o",
api_key="sk-...",
messages=[{"role": "user", "content": "Weather in Tokyo?"}],
tools=[weather_tool],
)
Vision (multimodal)
response = completion(
model="openai/gpt-4o",
api_key="sk-...",
messages=[{
"role": "user",
"content": [
{"type": "text", "text": "Describe this image."},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}},
],
}],
)
Reusable client (connection pooling)
from universal_llm_connector import UniversalClient
with UniversalClient(
base_url="https://your-gateway.example.com/v1",
api_key="token",
use_system_certs=True,
) as client:
r1 = client.completion(model="openai/gpt-4o", messages=[...])
r2 = client.completion(model="openai/gpt-4o-mini", messages=[...])
embedding = client.embed(model="openai/text-embedding-3-small", input="hello")
SSL Certificate Fix
Python's certifi uses a static CA bundle that does not include certificates from the OS trust store. This causes SSL failures in environments where additional CAs are installed at the OS level.
Fix for all Python HTTP libraries
from universal_llm_connector import corporate_fix
corporate_fix()
This exports the OS certificate store to a PEM file and configures requests, urllib3, httpx, aiohttp, pip, and git to use it via environment variables and session patching.
Fix for HuggingFace
from universal_llm_connector import configure_huggingface
configure_huggingface()
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
Advanced configuration
corporate_fix(
ca_bundle="/path/to/custom-ca.pem",
proxy="http://proxy.example.com:8080",
hf_endpoint="https://hf.example.com",
hf_token="hf_xxxxx",
pip_index_url="https://pypi.example.com/simple",
verbose=True,
)
Supported Providers
| Provider | Model format | Default base URL |
|---|---|---|
| OpenAI | openai/gpt-4o |
https://api.openai.com/v1 |
| Anthropic | anthropic/claude-sonnet-4-20250514 |
https://api.anthropic.com/v1 |
| Azure OpenAI | azure/my-deployment |
(requires base_url) |
| Google Gemini | gemini/gemini-1.5-pro |
https://generativelanguage.googleapis.com/v1beta |
| AWS Bedrock | bedrock/anthropic.claude-3-sonnet |
(requires base_url) |
| Groq | groq/llama-3.1-70b |
https://api.groq.com/openai/v1 |
| Mistral | mistral/mistral-large-latest |
https://api.mistral.ai/v1 |
| GitHub Models | github/gpt-4o |
https://models.inference.ai.azure.com |
| Ollama | ollama/llama3.1 |
http://localhost:11434 |
| HuggingFace | huggingface/meta-llama/Llama-3.1-8B |
https://api-inference.huggingface.co |
All providers support custom base_url for self-hosted or gateway endpoints.
API Reference
completion() / acompletion()
| Parameter | Type | Description |
|---|---|---|
model |
str |
Required. Format: provider/model-name |
messages |
list |
Conversation messages |
input |
str or list |
Input for OpenAI Responses API |
api |
str |
"chat" (default) or "responses" |
stream |
bool |
Enable streaming (default: False) |
base_url |
str |
Provider or gateway URL |
api_key |
str |
Authentication key |
timeout |
float |
Timeout in seconds (default: 60) |
max_retries |
int |
Retries on 429/5xx (default: 3) |
use_system_certs |
bool |
Use OS certificate store (default: False) |
tools |
list |
Tool/function definitions |
embed() / aembed()
| Parameter | Type | Description |
|---|---|---|
model |
str |
Required. Format: provider/model-name |
input |
str or list[str] |
Required. Text(s) to embed |
base_url |
str |
Provider or gateway URL |
api_key |
str |
Authentication key |
ChatResponse
| Property | Type | Description |
|---|---|---|
.content |
str |
Generated text (first choice) |
.finish_reason |
str |
"stop", "length", "tool_calls" |
.usage.total_tokens |
int |
Total tokens |
.model |
str |
Model that served the request |
.raw |
dict |
Full provider response |
EmbedResponse
| Property | Type | Description |
|---|---|---|
.embedding |
list[float] |
First embedding vector |
.embeddings |
list[list[float]] |
All vectors (batch input) |
Error Handling
from universal_llm_connector.exceptions import (
AuthenticationError, # 401/403
RateLimitError, # 429, includes retry_after
ModelNotFoundError, # 404
ContextLengthError, # Input too long
NetworkError, # Connection/timeout
SSLCertificateError, # Cert verification failed
InvalidRequestError, # 400
)
Development
git clone https://github.com/rs2pydev/universal-llm-connector.git
cd universal-llm-connector
pip install -e ".[dev]"
pytest # 81 unit tests
ruff check src/ tests/ # Lint
mypy src/ # Type check
python -m build # Build wheel + sdist
Requirements
- Python 3.10+
- httpx >= 0.27
- pydantic >= 2.0
- tenacity >= 8.0
- truststore >= 0.9
- certifi
License
MIT
Metadata
Release files for universal-llm-connector 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| universal_llm_connector-1.0.0.tar.gz | 39.3 kB | With provenance | Details for universal_llm_connector-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| universal_llm_connector-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for universal_llm_connector-1.0.0-py3-none-any.whl |
Total release size: 84.3 kB
Release files / universal_llm_connector-1.0.0.tar.gz
| Download URL | universal_llm_connector-1.0.0.tar.gz |
|---|---|
| Size | 39.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2e0784fd6934dcb035b449404c8e624d3255a76e71906ef61cf6ef8932ae2617
|
|
BLAKE2b-256 checksum How to use checksums |
7642b2ef68e27edac584339871c3188bdd8bf59e0f58caaf836f1a9b4e4a701c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.
Transparency logRelease files / universal_llm_connector-1.0.0-py3-none-any.whl
| Download URL | universal_llm_connector-1.0.0-py3-none-any.whl |
|---|---|
| Size | 45.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ec326b2250b6cadc311ad3b80242148ab55f78f2d62d75f06279730848598cf5
|
|
BLAKE2b-256 checksum How to use checksums |
005946dfc9acc6eae3162ce14912d7a4ba6856c795192fbbb4a5bfd9ba04d173
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.
Transparency logSecurity for universal-llm-connector 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for universal_llm_connector-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.