dr-providers
| Repo Definitions (terms, contracts) | dr-serialize |
|---|
dr-providers makes LLM provider calls through explicit, typed contracts. It supports OpenRouter, OpenAI, Gemini, and Anthropic while keeping call identity, provider translation, transport policy, and outcomes separate.
Package map
| Package | Responsibility |
|---|---|
dr_providers.modeling |
Identity-bearing definitions, configs, requests, routes, controls, and transcripts |
dr_providers.translation |
Pure provider request-body construction and parsed-response translation |
dr_providers.transport |
Credentials, endpoints, timeout and native-retry policy, and HTTP execution |
dr_providers.outcomes |
Typed responses, expected failures, invocation evidence, and conformance warnings |
dr_providers.core |
Shared provider protocol and failure vocabulary |
dr_providers.surfaces.testing |
Deterministic ScriptedProvider for network-free tests |
dr_providers.surfaces.cli |
Optional dr-providers one-shot CLI |
dr_providers.surfaces.serve |
Optional localhost FastAPI facade |
The top-level dr_providers exports are the stable import surface. The
functional-area module paths make ownership discoverable but are not a second
public API to mirror in application imports.
Install
dr-providers requires Python 3.12 or newer.
uv add dr-providers
Unless an API key is injected directly, real HTTP calls read the credential selected by their transport policy:
| Provider | Environment variable |
|---|---|
| OpenRouter | OPENROUTER_API_KEY |
| OpenAI | OPENAI_API_KEY |
| Gemini | GEMINI_API_KEY |
| Anthropic | ANTHROPIC_API_KEY |
Python quickstart
This OpenAI example uses only names exported by dr_providers:
from dr_providers import (
GenerationControls,
HttpProvider,
MessageRole,
PromptMessage,
ProviderCallRequest,
ProviderKind,
Transcript,
is_response,
openai_responses_config,
policy_for,
)
config = openai_responses_config(
model="gpt-5-mini",
controls=GenerationControls(token_limit=256),
)
request = ProviderCallRequest(
config=config,
transcript=Transcript(
messages=(
PromptMessage(
role=MessageRole.USER,
content="Say hello in one word.",
),
)
),
)
with HttpProvider(policy=policy_for(ProviderKind.OPENAI)) as provider:
outcome = provider.complete(request)
if is_response(outcome):
print(outcome.text)
else:
print(f"{outcome.code}: {outcome.message}")
Expected transport failures are returned as
ProviderTransportFailure values. Unexpected programming or infrastructure
errors can still raise.
CLI and local server
Install and run the one-shot CLI:
uv add 'dr-providers[cli]'
uv run dr-providers --provider openai-responses \
--model gpt-5-mini \
--token-limit 256 \
-m 'Say hello in one word.'
Install the serving extra and bind the FastAPI facade to localhost:
uv add 'dr-providers[serve]'
uv run python -m dr_providers.surfaces.serve serve --port 8322
Outcome and evidence boundaries
HttpProvider.complete() returns a closed
ProviderTransportResponse | ProviderTransportFailure union for expected
transport results. The timeout plus a fixed five-second operational margin
bounds each native attempt's caller-visible wait; aggregate latency scales
with native_retry_count + 1. When a caller injects its own synchronous HTTP
client, a timed-out attempt can leave a daemon worker and socket lingering
until the caller-owned operation eventually ends.
HttpProvider.invoke() returns versioned serializable invocation evidence:
request and policy identity payloads, structured request metadata, the
constructed JSON request-body mapping, and the response body decoded as JSON
when possible or retained as text otherwise. It does not retain original HTTP
wire bytes. The standard HttpProvider path redacts known credential header
names; direct ProviderHttpRequestEvidence construction and deserialization
remain trusted-data paths. Evidence fields containing dictionaries remain
mutable after construction, so callers should serialize the snapshot before
sharing or persistence.
Repository validation
The default suite is offline: pytest excludes tests marked live.
uv sync --locked --all-extras
uv run pre-commit install
scripts/pre-check.sh
uv build
Run the complete live matrix without changing the committed wire corpus:
uv run python scripts/run_live_matrix.py
Capturing and promoting replacement corpus data is a separate, deliberate
operation. It stages outside the repository, validates and redacts the
complete five-case capture, then updates data/wire-corpus/:
uv run python scripts/capture_live_corpus.py capture --promote
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 dr_providers-0.2.2.tar.gz.
File metadata
- Download URL: dr_providers-0.2.2.tar.gz
- Upload date:
- Size: 28.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 |
0ae13d1e7172c5d27afad06d3c28bdeacfe68648c1d7563e9a8b6ae14b34df61
|
|
| MD5 |
17267b53f9671643b0af423844e6ed12
|
|
| BLAKE2b-256 |
29de31905c2f51bdc06ca8678a514c3ccc28212d55dc36f7af79817e02c89263
|
Provenance
The following attestation bundles were made for dr_providers-0.2.2.tar.gz:
Publisher:
release.yaml on danielle-rothermel/dr-providers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dr_providers-0.2.2.tar.gz -
Subject digest:
0ae13d1e7172c5d27afad06d3c28bdeacfe68648c1d7563e9a8b6ae14b34df61 - Sigstore transparency entry: 2353274767
- Sigstore integration time:
-
Permalink:
danielle-rothermel/dr-providers@4397f527bc25cd9fe58cace6b68fd343dc201944 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/danielle-rothermel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@4397f527bc25cd9fe58cace6b68fd343dc201944 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dr_providers-0.2.2-py3-none-any.whl.
File metadata
- Download URL: dr_providers-0.2.2-py3-none-any.whl
- Upload date:
- Size: 45.0 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 |
6054cc6e129efa718cbfd9def83d474aa08623bda3b2920414c2951ff3dc8e27
|
|
| MD5 |
eabcfe89c7ee1c585bc7f2b0bb5b6e79
|
|
| BLAKE2b-256 |
aa8e1691a9c173564dd792282767b8b901c6536050361c492eac05892554c3af
|
Provenance
The following attestation bundles were made for dr_providers-0.2.2-py3-none-any.whl:
Publisher:
release.yaml on danielle-rothermel/dr-providers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dr_providers-0.2.2-py3-none-any.whl -
Subject digest:
6054cc6e129efa718cbfd9def83d474aa08623bda3b2920414c2951ff3dc8e27 - Sigstore transparency entry: 2353274929
- Sigstore integration time:
-
Permalink:
danielle-rothermel/dr-providers@4397f527bc25cd9fe58cace6b68fd343dc201944 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/danielle-rothermel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@4397f527bc25cd9fe58cace6b68fd343dc201944 -
Trigger Event:
push
-
Statement type: