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
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 universal_llm_connector-1.0.0.tar.gz.
File metadata
- Download URL: universal_llm_connector-1.0.0.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e0784fd6934dcb035b449404c8e624d3255a76e71906ef61cf6ef8932ae2617
|
|
| MD5 |
4ef4b03bf3d3f100d1149ec0050dd0a9
|
|
| BLAKE2b-256 |
7642b2ef68e27edac584339871c3188bdd8bf59e0f58caaf836f1a9b4e4a701c
|
Provenance
The following attestation bundles were made for universal_llm_connector-1.0.0.tar.gz:
Publisher:
publish.yml on rs2pydev/universal-llm-connector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
universal_llm_connector-1.0.0.tar.gz -
Subject digest:
2e0784fd6934dcb035b449404c8e624d3255a76e71906ef61cf6ef8932ae2617 - Sigstore transparency entry: 2662992281
- Sigstore integration time:
-
Permalink:
rs2pydev/universal-llm-connector@f21e05e67babb8abfb8d8e5d1ef25e30f060e002 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/rs2pydev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f21e05e67babb8abfb8d8e5d1ef25e30f060e002 -
Trigger Event:
push
-
Statement type:
File details
Details for the file universal_llm_connector-1.0.0-py3-none-any.whl.
File metadata
- Download URL: universal_llm_connector-1.0.0-py3-none-any.whl
- Upload date:
- Size: 45.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec326b2250b6cadc311ad3b80242148ab55f78f2d62d75f06279730848598cf5
|
|
| MD5 |
cebe3558623ab5c5791edf6e13eed315
|
|
| BLAKE2b-256 |
005946dfc9acc6eae3162ce14912d7a4ba6856c795192fbbb4a5bfd9ba04d173
|
Provenance
The following attestation bundles were made for universal_llm_connector-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on rs2pydev/universal-llm-connector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
universal_llm_connector-1.0.0-py3-none-any.whl -
Subject digest:
ec326b2250b6cadc311ad3b80242148ab55f78f2d62d75f06279730848598cf5 - Sigstore transparency entry: 2662992379
- Sigstore integration time:
-
Permalink:
rs2pydev/universal-llm-connector@f21e05e67babb8abfb8d8e5d1ef25e30f060e002 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/rs2pydev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f21e05e67babb8abfb8d8e5d1ef25e30f060e002 -
Trigger Event:
push
-
Statement type: