NiceKit is a platform framework package, not a utility library. It was extracted from a
production enterprise AI application. Install it, wire it up, and your project gets a multi-tenant
foundation, an LLM routing layer, an agent runtime, a knowledge base and operational
observability — 228 REST endpoints across 182 paths, 64 tables, 46 of them under
PostgreSQL FORCE ROW LEVEL SECURITY.
pip install nicekit
from nicekit.api.v1.router import default_routers
from nicekit.runtime.app_factory import create_app
from nicekit.runtime.bootstrap import install_default_ports
install_default_ports()
app = create_app(routers=default_routers())
That is a running platform with authentication, model configuration, knowledge bases and agent chat — provided the infrastructure below is in place.
Requirements
Hard dependencies, none of them substitutable:
- Python 3.13+
- PostgreSQL with
pgvector,pg_trgm,zhparserandpgcrypto - Redis
- S3-compatible object storage
- Celery is optional — there is an inline dispatch fallback
pip install nicekitalone will not give you a running system. The repository ships adocker composesetup and a custom PostgreSQL image with the three extensions pre-built; the officialpostgresimage will fail migrations.
What you get
| Area | What you get |
|---|---|
| Multi-tenancy | Orgs / users / memberships / invitations, JWT + rotating refresh tokens, PostgreSQL FORCE ROW LEVEL SECURITY (binds even the table owner; policies evaluate false when no context is set), three integration modes |
| LLM layer | OpenAI / Anthropic dual-protocol normalization, model capability registry, model-ID normalization, routing and fallback chains, provider cooldown, per-org budget and concurrency gates, four-bucket token metering |
| Agent runtime | Multi-turn tool loop, seven-axis permission approval, AI reviewer, MCP client, SKILL.md skills, sub-agent delegation, long-term memory, session-goal continuation, context compression, scheduled tasks that start a real agent run |
| Knowledge base | Ingestion (Docling layout understanding, structure-aware chunking, contextualization, embedding), generic entity extraction and review, snapshot publish/rollback, four-channel hybrid retrieval (structured + sparse + dense + graph, fused with RRF), knowledge graph, wiki generation, media review, prompt-injection guardrails |
| Operations | Health/readiness probes, Prometheus metrics, service heartbeats, provider connectivity probes, orphan task recovery, stale sweeps, transactional outbox |
| API | 18 routers and 228 endpoints under /api/v1 |
Deliberately not included: any domain model. No orders, tickets, projects or customers — you define those and plug them in through extension points. NiceKit also does not abstract over the database (PostgreSQL is required by design) and ships no industry vocabularies.
Bridging your existing identity system
Authentication converges on a single dependency. Replace the PrincipalResolver behind it and the
SDK plugs into whatever account system you already have — you change assembly code, not the data
model.
from nicekit.api.deps import Principal, set_principal_resolver
from nicekit.api.v1.router import AUTH_ROUTER_NAMES, default_routers
from nicekit.tenancy import subject_uuid, tenant_uuid
async def resolver(request) -> Principal:
claims = verify_host_token(request.headers["authorization"])
return Principal(
org_id=tenant_uuid(claims["company_id"]), # external key -> UUID, deterministic, no mapping table
user_id=subject_uuid(claims["user_id"]),
role=ROLE_MAP[claims["role"]],
)
set_principal_resolver(resolver) # must happen before create_app
app = create_app(routers=default_routers(exclude=AUTH_ROUTER_NAMES))
Three modes are supported: managed (SDK owns identity), bridged (your app owns it) and single-tenant (no tenant concept, or auth at the gateway).
Extension points
The SDK never imports host code. Everything domain-specific goes through registration interfaces — custom tools with seven-axis permissions, resource resolvers, context providers, entity types, notifiers, trace/usage sinks, roles, scheduled tasks and more.
from nicekit.agent.tools import ToolContext, ToolRegistry, tool_permission
from nicekit.domain.agent_permission import (
PermissionScope, ToolCategory, ToolDelegation, ToolEffect, ToolReversibility, ToolRisk,
)
my_tools = ToolRegistry("myapp")
@my_tools.register(
"ticket_close",
"Close a ticket",
{"type": "object", "properties": {"ticket_id": {"type": "string"}},
"required": ["ticket_id"], "additionalProperties": False},
permission=tool_permission(
effect=ToolEffect.TRANSITION,
risk=ToolRisk.SENSITIVE,
categories=(ToolCategory.WORKFLOW,),
reversibility=ToolReversibility.COMPENSATABLE,
delegation=ToolDelegation.REVIEWABLE, # requires AI review or human approval
scope=PermissionScope.RESOURCE,
material_arguments=("ticket_id",),
),
)
async def ticket_close(ctx: ToolContext, args: dict) -> dict:
...
app = create_app(routers=default_routers(), tool_registry=my_tools)
Documentation
Full documentation lives in the repository. It is written in Chinese; the repository also has an English overview.
- Documentation index
- SDK guide — 30-minute start, all extension points, common recipes
- Integration guide — bridging an existing tenancy and auth system
- Agent brief — structured, copy-pasteable facts written for AI coding assistants
- Data model — all 64 tables and the RLS mechanism
Status
0.1.2. The public API is not frozen. During 0.x, minor versions may carry breaking changes —
read the changelog
before upgrading.
License
Apache License 2.0 © 2026 patrickleehua
Metadata
Release files for nicekit 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nicekit-0.1.2.tar.gz | 1.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nicekit-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 2.1 MB
Release files / nicekit-0.1.2.tar.gz
| Download URL | nicekit-0.1.2.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2d2cd236e794465370a511a55f0f54b1f728ce4ec8d9558626dc9d8a80f8c86
|
|
BLAKE2b-256 checksum How to use checksums |
e07165d0ee102c132dabe3531e9be169046846db0e649d6bbb3da926db1e97c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.
Transparency logRelease files / nicekit-0.1.2-py3-none-any.whl
| Download URL | nicekit-0.1.2-py3-none-any.whl |
|---|---|
| Size | 938.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
45c2ee1c6e1d963f1c5af080910f4a77de264a6c117c77f5f3820378e81a072d
|
|
BLAKE2b-256 checksum How to use checksums |
6913f9ae273024ff65b6b95f95206db0607cc595371d8f2c140fd2031ba60109
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 6, 2026.
Transparency log