Skip to main content
NiceKit

NiceKit

A multi-tenant Agent + Knowledge Base platform SDK for Python

PyPI Python License

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, zhparser and pgcrypto
  • Redis
  • S3-compatible object storage
  • Celery is optional — there is an inline dispatch fallback

pip install nicekit alone will not give you a running system. The repository ships a docker compose setup and a custom PostgreSQL image with the three extensions pre-built; the official postgres image 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.

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

Download files

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

Source Distribution

nicekit-0.1.2.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

nicekit-0.1.2-py3-none-any.whl (938.7 kB view details)

Uploaded Python 3

File details

Details for the file nicekit-0.1.2.tar.gz.

File metadata

  • Download URL: nicekit-0.1.2.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nicekit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b2d2cd236e794465370a511a55f0f54b1f728ce4ec8d9558626dc9d8a80f8c86
MD5 9581ae5f69d14f926a48d131bb95202e
BLAKE2b-256 e07165d0ee102c132dabe3531e9be169046846db0e649d6bbb3da926db1e97c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for nicekit-0.1.2.tar.gz:

Publisher: release.yml on patrickleehua/nice-knowledge

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

File details

Details for the file nicekit-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: nicekit-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 938.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for nicekit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 45c2ee1c6e1d963f1c5af080910f4a77de264a6c117c77f5f3820378e81a072d
MD5 36e54f5575b22bf37613c22c17ba2508
BLAKE2b-256 6913f9ae273024ff65b6b95f95206db0607cc595371d8f2c140fd2031ba60109

See more details on using hashes here.

Provenance

The following attestation bundles were made for nicekit-0.1.2-py3-none-any.whl:

Publisher: release.yml on patrickleehua/nice-knowledge

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