lm15 Python reference implementation — provider-neutral, low-level foundation for LLM APIs. Legacy 0.2.x on the legacy-0.2 branch.
README
lm15 is a small, typed, provider-neutral interface for foundation-model requests, responses, streams, tools, media parts, endpoint APIs, errors, and canonical JSON serialization. This repository is its Python reference implementation.
What lm15 is — and deliberately is not. lm15 is a low-level foundation
library: one canonical representation, exact serde for it, and adapters that
translate it to and from each provider's wire format — stdlib-only, with its
own HTTP transport (websockets is the single optional extra, for live
sessions). It is NOT an opinionated user-facing API: no magic call(), no
automatic tool loops, no DSL. lm15 is meant to be the dependency for
libraries that want to build their own take on the right way to talk to AI
systems in Python — you bring the opinions, lm15 brings every provider.
The public API is the top-level package: from lm15 import AnthropicLM, Request, Message, ... (see lm15/__init__.py for the full curated surface).
Transport plumbing stays under lm15.transports, live sessions under
lm15.live, and the conformance shim under lm15.vet.
The code blocks below are documentation that runs: every output block is
the real, captured output of the example above it.
Measured by benchmarks/suite/run.py on Python 3.13.3 — methodology and full results in benchmarks/BENCHMARKS.md:
| package | install size | transitive deps | cold import | import RSS | |---|---:|---:|---:|---:| | lm15 | 0.5 MiB | 0 | 152 ms | 16.6 MiB | | openai | 18.0 MiB | 15 | 468 ms | 35.3 MiB | | anthropic | 17.1 MiB | 15 | 589 ms | 41.2 MiB | | google-genai | 37.2 MiB | 24 | 934 ms | 60.8 MiB | | litellm | 133.0 MiB | 54 | 2298 ms | 161.0 MiB | | langchain-openai | 63.3 MiB | 35 | 930 ms | 61.0 MiB |
<!-- footprint:generated:end -->python3 -m pip install lm15
# Optional extra for websocket live sessio