llm-client-kit
Cached, fixture-aware LLM client with Ollama (default) and Anthropic provider dispatch. Carved out of resume-builder/src/resume_builder/llm_client.py so it can be shared across internal Python apps without each app rolling its own dispatch + caching layer.
PyPI: jsmithpkp-llm-client-kit. Import path stays llm_client_kit (PyPI distribution name and Python import name are allowed to differ).
Install
pip install jsmithpkp-llm-client-kit
For the Anthropic provider path, install the extra:
pip install 'jsmithpkp-llm-client-kit[anthropic]'
Public API
from llm_client_kit import (
LLMClient,
LLMResponse,
LLMEndpointUnreachableError,
AnthropicProviderError,
PROVIDER_OLLAMA,
PROVIDER_ANTHROPIC,
)
Construct from env (resume-builder-compatible)
client = LLMClient.from_env() # reads RESUME_BUILDER_LLM_* env vars
result = client.complete_json(
namespace="my_stage",
system_prompt="You are a JSON-only classifier...",
user_payload={"subject": "...", "body": "..."},
)
Env vars honored:
| Env var | Default | Notes |
|---|---|---|
RESUME_BUILDER_LLM_PROVIDER |
ollama |
ollama or anthropic |
RESUME_BUILDER_LLM_API_URL |
provider-default | OpenAI-compat for Ollama; ignored by Anthropic adapter |
RESUME_BUILDER_LLM_MODEL |
llama3.1:8b / claude-sonnet-4-6 |
per-provider default |
RESUME_BUILDER_LLM_API_KEY / ANTHROPIC_API_KEY |
unset | required for Anthropic |
RESUME_BUILDER_LLM_TIMEOUT_SECONDS |
90 |
per-request timeout |
RESUME_BUILDER_LLM_TIMEOUT_<NAMESPACE> |
unset | per-stage timeout override |
RESUME_BUILDER_LLM_MAX_TOKENS |
2048 |
Anthropic only |
RESUME_BUILDER_LLM_FIXTURE |
0 |
fixture mode (no network calls; cache-only) |
RESUME_BUILDER_LLM_CACHE_DIR |
.llm_cache / tests/fixtures/llm_cache (fixture mode) |
response cache location |
The env var prefix
RESUME_BUILDER_LLM_*is preserved from the carve-out source for v0.1.0 backward compat. A future release will parameterize the prefix so consumers can use their own namespace.
Construct directly (no env)
from pathlib import Path
from llm_client_kit import LLMClient, PROVIDER_OLLAMA
client = LLMClient(
endpoint="http://localhost:11434/v1/chat/completions",
model="llama3.2:3b",
cache_dir=Path("./.cache"),
fixture_mode=False,
timeout_seconds=30.0,
provider=PROVIDER_OLLAMA,
)
Error contract
complete_json documents three failure modes:
ValueError— invalid / non-object JSON response, malformed cache payload.RuntimeError— provider-agnostic failures (cache I/O, fixture-mode miss) AND Ollama-path transport/parse failures.LLMEndpointUnreachableError(RuntimeErrorsubclass) — connection refused / DNS failure / host unreachable, on the Ollama path.AnthropicProviderError(NOT aRuntimeErrorsubclass) — any failure on the Anthropic path. Intentionally outside the(RuntimeError, ValueError)fallback chain: a paid API call halting loudly is better than silently degrading.
See class docstrings for the full rationale.
Releasing
Releases are automated. Tag-triggered workflow at .github/workflows/release.yml:
- Bump
versioninpyproject.tomland__version__insrc/llm_client_kit/__init__.pyon a PR. - After the PR merges, tag
vX.Y.Zonmainand push the tag. - The
releaseworkflow runsgitleaksagainst the working tree AND full git history — any finding aborts the workflow before the build. Thenpython -m buildproduces sdist + wheel, andpypa/gh-action-pypi-publishuploads via PyPI Trusted Publisher OIDC (no API token stored in repo secrets).
# example bump-and-release flow
git switch main && git pull
# (PR merged that bumps version to 0.1.4)
git tag v0.1.4
git push origin v0.1.4
# watch: gh run watch
The secret-scan step is mandatory and is the only thing standing between an accidentally-committed credential and a published wheel. Do not edit the workflow to skip it without first understanding what it catches.
Metadata
Release files for jsmithpkp-llm-client-kit 0.1.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jsmithpkp_llm_client_kit-0.1.4.tar.gz | 15.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jsmithpkp_llm_client_kit-0.1.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.7 kB
Release files / jsmithpkp_llm_client_kit-0.1.4.tar.gz
| Download URL | jsmithpkp_llm_client_kit-0.1.4.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
903e805bd21a70d735df15f5731d85a5bc27f93fe5799fdfb5a3d6736b558a15
|
|
BLAKE2b-256 checksum How to use checksums |
084896b0dd91de7eb5d54ac78d4c850a5d7d15d9f6791e7f3b7a71a36bccd681
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 1, 2026.
Transparency logRelease files / jsmithpkp_llm_client_kit-0.1.4-py3-none-any.whl
| Download URL | jsmithpkp_llm_client_kit-0.1.4-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
057862d866fdd54cd22cfafcd821506cc7ccef5bef361606ce8248d39c332a0b
|
|
BLAKE2b-256 checksum How to use checksums |
1e2bddda840341a8c5fb1c789d9103683429329fdb09d469c3785da5a9526fd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 1, 2026.
Transparency log