Skip to main content

spawnllm

Delete your subprocess wrappers around claude, codex, and gemini. spawnllm subshells all three CLIs plus local MLX and returns one Pydantic-validated Response, so the per-model plumbing you hand-rolled goes away.

CI PyPI License: MIT

Get started

uvx spawnllm status
Terminal running 'uvx spawnllm status' — every backend reports ready and auto-selection picks claude

Driving with an agent? Paste this:

Run `uv add spawnllm` in this project.
Replace our hand-rolled claude/codex subprocess code with spawnllm's `call_sync`,
or `extract_sync` with a Pydantic response model for structured output.
Verify available backends with `uvx spawnllm status`.
Docs: https://yasyf.github.io/spawnllm/

Use cases

Delete your hand-rolled claude/codex subprocess plumbing

Every small tool grows its own subprocess.run(["claude", "-p", ...]) — argv quirks, stdin piping, exit-code guesswork — and each copy drifts. One call replaces all of it:

from spawnllm import call_sync

print(call_sync("Reply with just the word: pong"))

Prints pong. With no backend=, spawnllm auto-selects the first installed, authenticated CLI, pipes the prompt over stdin, and retries transient 529/overloaded/rate-limit failures with capped backoff.

Get a validated Pydantic object back, not a string to parse

Scraping JSON out of a model's stdout means regexes, code fences, and silent schema drift. extract_sync validates instead:

from pydantic import BaseModel

from spawnllm import extract_sync


class Capital(BaseModel):
    country: str
    capital: str


result = extract_sync("What is the capital of France?", Capital)
print(result.capital)  # Paris

The backend turns Capital into a JSON-schema constraint on the call itself, and a non-conforming reply raises pydantic.ValidationError instead of sneaking downstream.

Run Apple-Silicon MLX models with fused adapters and prompt-cache reuse

Shipping a LoRA-tuned local model means hand-rolling adapter fusion, model caching, and worker-thread lifecycle. The MLX extra owns all three:

uv add "spawnllm[mlx]"

AdapterFuser.ensure_fused fuses your compressed adapter into the base model once and caches the result in the Hugging Face hub layout; MlxEngine loads it on a dedicated worker thread, precomputes a prompt cache for your shared prefix messages, and batches generation. Wrap the engine in an MlxBackend and the same run_sync call works.

More in the docs

  • Spec-driven runs — a literal model id, per-provider flag passthrough, and envelope-aware retry via RunSpecRunning reference
  • Backend selection — the priority chain, plus specialty= routing (debugging and review go to Codex, general to Claude) — Backends reference
  • Transport helpersrun_cli, collect_process, and map_concurrent, the subprocess plumbing shared by every CLI backend — Transport reference
  • The CLIspawnllm call, status, and backends from any shell — CLI reference
  • MLX internals — the adapter codec, fuser, and runtime patches behind the local engine — MLX reference

Read the docs for the full guide and API reference. Licensed under MIT.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spawnllm-0.6.0.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spawnllm-0.6.0-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

Details for the file spawnllm-0.6.0.tar.gz.

File metadata

  • Download URL: spawnllm-0.6.0.tar.gz
  • Upload date:
  • Size: 31.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spawnllm-0.6.0.tar.gz
Algorithm Hash digest
SHA256 4935bc53903a4289191cc73e6b3fea548191d60fac3f2a6afe3c2355a49c8ca8
MD5 8c5b86eff351b0c1482d696bd379e751
BLAKE2b-256 38f0e0d25497d91180d171b3778448bdb7262339af69eba6ab6c4bcbe06661a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for spawnllm-0.6.0.tar.gz:

Publisher: release-pypi.yml on yasyf/spawnllm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spawnllm-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: spawnllm-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 42.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for spawnllm-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ea041fced3376f7089563c3220053b49d379f1f54518c48557ebf4b88d48fbf
MD5 5b7d8e13b8c18d0f1d788c31a9b3b97e
BLAKE2b-256 f91cb9ab33e61eb48ba9a4741414c0be8ad9bba8d251af5b546fdd876a9c4a8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for spawnllm-0.6.0-py3-none-any.whl:

Publisher: release-pypi.yml on yasyf/spawnllm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page