Open-source building blocks

LLM Works provides a modular open-source platform that organizes the infrastructure layer between LLMs and agents. The libraries are hosted on GitHub and published on PyPI.

from llm_gent.flow import Role, Factory, planner, grader

analyst = Role("analyst", "anthropic", "claude-opus-5-5")

@planner(role=analyst)
async def plan(ctx, task): ...

@grader(role=analyst)
async def grade(ctx, result): ...

flow = Factory(lg, saia_factory=factory).create()
await flow.call(plan).call(grade).run()

Multi-role agentic flows

  • Mix models & providers per role
  • Fluent primitives: loops, fan-out, panels, branches
  • Pause/resume & crash resilience
  • Integrated cost tracking & boundaries
  • Runtime for agent swarms

pip install llm-gent

from llm_saia import SAIA

saia = SAIA.builder().backend(backend).build()

check = await saia.verify(code, "adds two numbers")

if not check.value.passed:
    crit = await saia.critique(check.value.reason)
    code = await saia.refine(
        code, crit.value.counter_argument)

Verb vocabulary for AI agents

  • ask, verify, critique, refine, extract, classify
  • Full inner loop with tool calling
  • Guard system with retries
  • Tracing system for transparency
  • Zero-dependency core

pip install llm-saia

tesla = kelt.kg.entities.create(
    scope_key="global",
    canonical_name="Tesla",
    entity_type="company",
    aliases=["TSLA", "Tesla Motors"])

elon, _ = kelt.kg.entities.find_or_create(
    "global", "Elon Musk", "person")

kelt.kg.relationships.add(elon, tesla.id,
    "founded", scope_key="global")

Knowledge · Embedding · Learning · Training

  • Atomic facts model & knowledge graph
  • Contexts, compaction & RAG
  • SFT & DPO fine-tuning with provenance (CAS)
  • Embedding quantization: f16, int8, int4

pip install llm-kelt

from llm_infer.client import Factory, FallbackClient

router = Factory(lg).from_config(config["llm"])
client = FallbackClient(lg, router,
    fallbacks={"qwen3.8-27b": "claude-opus-5-5"})

response = client.chat(messages, model="qwen3.8-27b")

Multi-provider/model inference routing

  • Role-based routing with fallback
  • Sync, async, streaming
  • Local models via Ollama or vLLM
  • Rate limits with backoff

pip install "llm-infer[client]"

from appinfra.app import AppBuilder

app = AppBuilder("mytool").build()

@app.tool(name="sync")
@app.argument("--limit", type=int)
def sync_tool(self):
    self.lg.info(f"limit={self.args.limit}")

Infrastructure for Python services

  • Fluent CLI builder
  • Enhanced YAML config with hot-reload
  • Multi-target structured logging
  • Service lifecycle with restart policies

pip install appinfra

Scores below are produced by the open-source grade-python-project grader, which runs against any Python project and has inspectable criteria. appinfra scoreboard:

CategoryScoreVerified by
Architecture & Design10.0/1022 packages, py.typed
Code Quality10.0/10mypy strict, ~200 files
Security10.0/10172 dedicated security tests
Testing10.0/1095% coverage, ~4800 tests
Documentation9.5/1015 guides, 18 API refs
Production Readiness10.0/10PyPI, semver, deprecations
Dependencies10.0/10clean pip-audit

Graded on June 24, 2026 against 81ef184 with Opus 4.7. These scores can be independently verified by running the grader against this commit with any model. Any LLM can review the criteria at the grader repo.

An appinfra CLI creates a SAIA object, connects to an Anthropic backend via llm-infer, and sends one request.

import sys, asyncio
from appinfra.app import AppBuilder
from llm_infer.client import Factory, SAIAAdapter
from llm_saia import SAIA

# build the CLI app via appinfra (provides self.lg, self.args, app.main)
app = AppBuilder("hello-llm").build()

# bind run() as the "run" subcommand with a positional "prompt" argument
@app.tool(name="run")
@app.argument("prompt")
def run(self):
    asyncio.run(_send(self.lg, self.args.prompt))

async def _send(lg, prompt):
    # open an async Anthropic client via llm-infer
    async with Factory(lg).anthropic() as client:
        # build a SAIA session using the llm-infer client as its backend
        saia = SAIA.builder().backend(SAIAAdapter(client)).build()
        # invoke the instruct verb to get a typed response
        print((await saia.instruct(prompt)).value)

if __name__ == "__main__":
    sys.exit(app.main())

Usage:

$ pip install appinfra llm-saia "llm-infer[anthropic,saia]"
$ export ANTHROPIC_API_KEY=sk-ant-...
$ python app.py run "What is systems engineering?"