Subshell + MLX LLM-calling backends (Claude/Codex CLI, local MLX) shared across tools.
Project description
spawnllm
Subshell + MLX LLM-calling backends (Claude/Codex CLI, local MLX) shared across tools.
spawnllm centralizes the LLM-calling plumbing that small tools keep re-inventing: driving the
claude and codex CLIs as subshells — with structured Pydantic output, model tiers, and
faithful error capture — and running local Apple-Silicon MLX models with adapter fusion,
prompt-cache reuse, and batched generation. Depend on it once and each tool keeps only its
domain logic instead of its own copy of the backends.
Install
Run the CLI with uvx:
uvx spawnllm --help
For the local MLX engine (Apple Silicon only), pull the extra: uv add "spawnllm[mlx]".
Quickstart
See which backends are installed and authenticated, and which one auto-selection picks:
uvx spawnllm status
claude: ready
codex: ready
selected: claude
Make a request by passing a prompt as the argument, or piping it over stdin:
uvx spawnllm call --backend claude "What is 2+2? Reply with just the number."
4
--model small|medium|large swaps the tier, which each backend maps to a concrete model — the
claude backend resolves small to Haiku, medium to Sonnet, and large to Opus. Add
--agent to let the call use tools. Run uvx spawnllm --help for the full flag list.
From Python
call_sync runs one request and returns the response. With no backend, it auto-selects
the first installed, authenticated CLI (its async companion call mirrors the same
signature):
from spawnllm import call_sync
print(call_sync("Reply with just the word: pong"))
# pong
Pin a backend and tier explicitly, or pass a Pydantic model to get a validated object back instead of text:
from pydantic import BaseModel
from spawnllm import call_sync, ClaudeCliBackend
class Capital(BaseModel):
country: str
capital: str
result = call_sync(
"What is the capital of France?",
backend=ClaudeCliBackend(),
model="large",
response_model=Capital,
)
print(result.capital) # Paris
When you don't pin a backend, set specialty= to scope auto-selection by task. The
debugging and review specialties route to Codex, and general routes to Claude.
Spec-driven runs
For full control, build a RunSpec and execute it with run_sync (or its async companion
run). A RunSpec takes a literal provider model id — no tier mapping — and per-provider
flag passthrough via provider_configs. The call returns a RunResult with raw stdout,
stderr, and exit code, retrying transient 529/overloaded/rate-limit failures with backoff:
from spawnllm import run_sync, RunSpec, ClaudeConfig, ClaudeCliBackend
result = run_sync(
RunSpec(
prompt="What is 2+2? Reply with just the number.",
model="opus",
provider_configs={"claude": ClaudeConfig(permission_mode="bypassPermissions")},
),
backend=ClaudeCliBackend(),
)
print(result.stdout) # 4
How it works
Each backend holds plumbing that consumers would otherwise rebuild: the CLI backends own argv construction, stdin/stdout piping, stderr teeing, and turning non-zero exits into useful errors, and they turn a Pydantic model into a JSON-schema constraint plus a parsed, validated result. The MLX engine wraps adapter fusion, prompt-cache reuse, worker-thread lifecycle, and batched single-token generation. Tools that share the layer stay byte-for-byte consistent instead of drifting across diverging copies.
Docs
Read the docs for the full guide and API reference.
Project details
Release history Release notifications | RSS feed
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 spawnllm-0.5.1.tar.gz.
File metadata
- Download URL: spawnllm-0.5.1.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8d926d8048c66e54f9d78b2bf85f63af2278527f84b17d05c8eafe8d208bf5c
|
|
| MD5 |
1e946cf685e8e081719c829cef87d211
|
|
| BLAKE2b-256 |
40f533e40b389b71d00dd956200292267ac8de424cce09b8a7188d4ef3a34366
|
Provenance
The following attestation bundles were made for spawnllm-0.5.1.tar.gz:
Publisher:
release-pypi.yml on yasyf/spawnllm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spawnllm-0.5.1.tar.gz -
Subject digest:
b8d926d8048c66e54f9d78b2bf85f63af2278527f84b17d05c8eafe8d208bf5c - Sigstore transparency entry: 1937276657
- Sigstore integration time:
-
Permalink:
yasyf/spawnllm@2131355c3b0fc68c8f9255b39ed77a4225634526 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/yasyf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@2131355c3b0fc68c8f9255b39ed77a4225634526 -
Trigger Event:
push
-
Statement type:
File details
Details for the file spawnllm-0.5.1-py3-none-any.whl.
File metadata
- Download URL: spawnllm-0.5.1-py3-none-any.whl
- Upload date:
- Size: 39.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e926fa8db138bffe5c0744e14f1ee7e8905937ca863967d7ab51c379599d1ee
|
|
| MD5 |
250502a334454f5b47dedaf1d9dad9e5
|
|
| BLAKE2b-256 |
0e842cd7d07efd1ba292c5966d83b9129271722940727e4124d2cbb587092d12
|
Provenance
The following attestation bundles were made for spawnllm-0.5.1-py3-none-any.whl:
Publisher:
release-pypi.yml on yasyf/spawnllm
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spawnllm-0.5.1-py3-none-any.whl -
Subject digest:
6e926fa8db138bffe5c0744e14f1ee7e8905937ca863967d7ab51c379599d1ee - Sigstore transparency entry: 1937276837
- Sigstore integration time:
-
Permalink:
yasyf/spawnllm@2131355c3b0fc68c8f9255b39ed77a4225634526 -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/yasyf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@2131355c3b0fc68c8f9255b39ed77a4225634526 -
Trigger Event:
push
-
Statement type: