uc-llm-provider
Generic LLM provider abstraction for Python.
Anthropic, OpenAI, Google — and any OpenAI-compatible local model (Ollama, LM Studio, vLLM, llama.cpp).
Three usage modes: Library · Server · CLI
Install
pip install uc-llm-provider # core only
pip install "uc-llm-provider[anthropic]" # + Anthropic SDK
pip install "uc-llm-provider[openai]" # + OpenAI SDK
pip install "uc-llm-provider[server,cli]" # + Server + CLI
pip install "uc-llm-provider[all]" # everything
Library
from uc_llm_provider import get_provider, ChatRequest, ChatMessage
# Cloud
provider = get_provider({
"name": "anthropic",
"provider_type": "anthropic",
"api_key": "sk-ant-...",
"default_model": "claude-sonnet-4-20250514",
})
# Local (Ollama)
provider = get_provider({
"name": "ollama",
"provider_type": "ollama",
"api_base": "http://localhost:11434",
"default_model": "llama3.2",
})
# Any OpenAI-compatible endpoint
provider = get_provider({
"name": "lm-studio",
"provider_type": "openai_compatible",
"api_base": "http://localhost:1234/v1",
"default_model": "local-model",
})
# Chat
response = await provider.chat(ChatRequest(
messages=[ChatMessage(role="user", content="Hello")],
max_tokens=256,
))
print(response.content)
Streaming
async for chunk in provider.chat_stream(request):
if chunk.type == "content_delta":
print(chunk.content, end="", flush=True)
Custom provider
from uc_llm_provider import register_provider
from uc_llm_provider.providers.template import TemplateProvider
class MyProvider(TemplateProvider):
def _get_endpoint(self, path=""):
return "https://api.myprovider.com/v1/chat"
register_provider("myprovider", MyProvider)
Server
uc-llm-server --port 12290 --provider anthropic --model claude-sonnet-4-20250514
uc-llm-server --port 12290 --provider ollama --api-base http://localhost:11434 --model llama3.2
uc-llm-server --port 12290 --config server.yaml
Endpoints:
| Method | Path | Description |
|---|---|---|
| GET | /v1/health |
Provider status |
| GET | /v1/capabilities |
Supported tiers and features |
| GET | /v1/models |
Model list |
| GET | /v1/models/{id} |
Model detail |
| POST | /v1/chat |
Chat completion |
| POST | /v1/chat/stream |
Streaming chat (SSE) |
| POST | /v1/tokens/count |
Token count |
Config YAML:
provider: anthropic
model: claude-sonnet-4-20250514
api_key: "" # or set UC_LLM_API_KEY
log_mode: jsonl # jsonl | none
log_dir: ./logs
host: 0.0.0.0
cors_origins: ["*"]
CLI
uc-llm chat "Explain Playwright in one sentence"
uc-llm chat --interactive
uc-llm stream "Explain Playwright"
uc-llm models --provider ollama
uc-llm tokens "How many tokens is this?"
uc-llm health --provider anthropic
uc-llm config
Global options:
| Option | Env | Description |
|---|---|---|
--provider |
UC_LLM_PROVIDER |
Provider type |
--model |
UC_LLM_MODEL |
Model |
--api-key |
UC_LLM_API_KEY |
API key |
--api-base |
UC_LLM_API_BASE |
API base URL |
--log-mode |
UC_LLM_LOG_MODE |
jsonl or none |
Provider types
provider_type |
Provider |
|---|---|
anthropic |
Anthropic Claude |
openai |
OpenAI |
google |
Google Gemini |
ollama |
Ollama (local) |
openai_compatible |
Any OpenAI-compatible API |
lm_studio / lmstudio |
LM Studio |
vllm |
vLLM |
llamacpp |
llama.cpp server |
localai |
LocalAI |
Ollama extras
from uc_llm_provider import get_provider
ollama = get_provider({"provider_type": "ollama", "api_base": "http://localhost:11434"})
models = await ollama.list_local_models()
async for status in ollama.pull_model("mistral"):
print(status)
running = await ollama.is_running()
License
MIT · cuber IT service
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
uc_llm_provider-0.5.1.tar.gz
(35.6 kB
view details)
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 uc_llm_provider-0.5.1.tar.gz.
File metadata
- Download URL: uc_llm_provider-0.5.1.tar.gz
- Upload date:
- Size: 35.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01f15e08b7271b58a73b156f36d1f446f7f5799c20af47b14f67f35166f46b20
|
|
| MD5 |
78999b2e782a7a16b435dadfcdff44c9
|
|
| BLAKE2b-256 |
094141dd487149a362932a778ece652f02a534737cc6e896fa7dab0f32104c2f
|
File details
Details for the file uc_llm_provider-0.5.1-py3-none-any.whl.
File metadata
- Download URL: uc_llm_provider-0.5.1-py3-none-any.whl
- Upload date:
- Size: 46.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08df341b5ff11f26e86f1a122b2ef3374812e463fbcbf86edc04c116149bf745
|
|
| MD5 |
759a2e4246c5c940f45142835c1a2b79
|
|
| BLAKE2b-256 |
1b81d10a1f2a5f4b293d5d9a24c079c0ec99b590858ab00fda6fc48917595759
|