Provider Protocol
Anything with the right generate() signature is a provider. No inheritance, no registration, no base class.
Loomkit is a tiny, swappable LLM orchestration core — without LangChain-scale bloat. A Protocol, a few dataclasses, one optional provider.
pip install loomkitWhy Loomkit
v0 ships only what you need to call a model and swap backends later. Everything else is deliberately deferred.
Anything with the right generate() signature is a provider. No inheritance, no registration, no base class.
A handful of dataclasses. The smallest useful surface for chat-style generation.
One concrete provider via the official google-genai SDK. Optional extra — core stays zero-deps.
Streaming, tools, retries, and agents land through the Provider seam without breaking call sites.
Quickstart
Install the Gemini extra, set GEMINI_API_KEY (or GOOGLE_API_KEY), and call generate().
import osfrom loomkit import Messagefrom loomkit.providers.gemini import GeminiProvider # Reads GEMINI_API_KEY (or GOOGLE_API_KEY) from envprovider = GeminiProvider() resp = provider.generate( [ Message(role="system", content="You are concise."), Message(role="user", content="Name three primary colors."), ], model="gemini-2.5-flash", temperature=0.2,) print(resp.text)print(resp.finish_reason, resp.usage)Design
Provider is a typing.Protocol. Adding a new backend means writing one class with a generate() method matching the signature — no imports from loomkit, no inheritance, no registration.
Call sites typed against Provider accept any conforming class.
class MyProvider: def generate(self, messages, *, model, temperature=None, max_tokens=None, stop=None) -> Response: ... # No loomkit imports. No inheritance. No registration. # Call sites typed against Provider accept any conforming class.What's next
Features layer through the Provider seam without breaking existing call sites. No kitchen-sink framework, just composable surfaces.
Install
Core is zero-deps. Gemini and dev tooling are optional extras. Requires Python 3.10+.
Zero dependencies
pip install loomkitAdds google-genai
pip install 'loomkit[gemini]'Plus pytest
pip install 'loomkit[gemini,dev]'Start with the core. Swap providers. Layer agents when you need them — not before.