llm-provider-adapter
llm-provider-adapter is a small, synchronous Python library for calling LLM
chat providers through one stable request, response, retry, error, and
telemetry contract.
Version 0.1 supports OpenAI, Claude, DeepSeek, OpenRouter, and LiteLLM. It does not provide an Agent framework, persistence, secret storage, async calls, streaming, multimodal content, or automatic cross-provider fallback.
Install
Python 3.11 or newer is required. Install only the provider SDK you need:
pip install "llm-provider-adapter[openai]>=0.1.0,<0.2.0"
pip install "llm-provider-adapter[claude]>=0.1.0,<0.2.0"
pip install "llm-provider-adapter[deepseek]>=0.1.0,<0.2.0"
pip install "llm-provider-adapter[openrouter]>=0.1.0,<0.2.0"
pip install "llm-provider-adapter[litellm]>=0.1.0,<0.2.0"
Use [all] only when an application must expose every adapter. The core
distribution imports without any provider SDK.
Minimal chat
Credentials, model IDs, and endpoints are always explicit. The library never reads environment variables or persists secrets.
from llm_provider_adapter import ChatRequest
from llm_provider_adapter.providers import OpenAIProvider
provider = OpenAIProvider(api_key="...")
response = provider.chat(
ChatRequest(
model="gpt-5-mini",
messages=[{"role": "user", "content": "Return one short greeting."}],
timeout_seconds=30,
)
)
print(response.content)
No real request is made when using the fake example:
python examples/fake_chat.py
Tool calling
Tools use the OpenAI function-tool shape at the public boundary. Provider
adapters translate it when required and normalize returned calls into
ToolCall(id, name, arguments).
request = ChatRequest(
model="gpt-5-mini",
messages=[{"role": "user", "content": "Weather in Shanghai?"}],
tools=[
{
"type": "function",
"function": {
"name": "weather",
"description": "Read weather for a city.",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
},
}
],
tool_choice="auto",
)
Unsupported capabilities fail before the SDK request when possible. Parameters are never silently discarded to make a request succeed.
Errors, retries, and timeout
RetryPolicyowns one bounded retry loop; SDK/LiteLLM retries are disabled.- Authentication, invalid request, capability, and context-limit failures do not retry.
- Any recognized timeout, including an SDK-default timeout when the request
omits
timeout_seconds, is never automatically replayed because the upstream may already have accepted or billed the request. - The library never changes provider automatically.
- Public errors and retry records omit raw SDK exception text, payloads, headers, credentials, and response bodies.
Catch LLMProviderError for normalized provider failures and
MissingProviderExtraError when the selected optional SDK is absent.
Telemetry
Pass an object implementing TelemetryObserver.on_event(event) to a provider.
Request, response, retry, and error events include provider/model identifiers,
counts, status classifications, request IDs, and normalized usage only. They do
not include messages, tool arguments, headers, raw payloads, arbitrary request
metadata, or raw exception text. Observer failures never change the chat call.
Documentation
Development
uv sync --all-extras --all-groups
uv run ruff check .
uv run mypy src tests
uv run pytest -q
uv build
uv run twine check dist/*
The project is licensed under the MIT License.
Metadata
Release files for llm-provider-adapter 0.1.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 | |
|---|---|---|---|
| llm_provider_adapter-0.1.0.tar.gz | 201.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_provider_adapter-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 230.4 kB
Release files / llm_provider_adapter-0.1.0.tar.gz
| Download URL | llm_provider_adapter-0.1.0.tar.gz |
|---|---|
| Size | 201.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d84fc296a239417aa46616f385b6eab8ec2e53c1f067453ce2a591a036c1aa63
|
|
BLAKE2b-256 checksum How to use checksums |
28651ad1a33d634640e8e5d1c7bad5534b7b54864e88279f320c52bc925e468d
|
| 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 11, 2026.
Transparency logRelease files / llm_provider_adapter-0.1.0-py3-none-any.whl
| Download URL | llm_provider_adapter-0.1.0-py3-none-any.whl |
|---|---|
| Size | 29.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43a0526133087d6d06897cd781a5732e337345b55b11b79a16c3bf5f4531d868
|
|
BLAKE2b-256 checksum How to use checksums |
22a4426603f9016518690b429c25bedcf20dfb17ca86f2114560813acbb37201
|
| 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 11, 2026.
Transparency log