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.0. 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.0.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.0-py3-none-any.whl (938.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nicekit-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 87f42701e8c52797f442d9745af7aa3ca5329602e28d993c24432c7dee1b085e
MD5 dbccea7d19208b6a5ee1b03e70e0f90a
BLAKE2b-256 51c6574a473a56d340041f99d0ce42d21f588237d188a53d8a8f68c8a0b36477

See more details on using hashes here.

Provenance

The following attestation bundles were made for nicekit-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: nicekit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 938.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f7cd081686676dc61d7014128b166a7c2d204ebaa77c9c0f82d77eb64c1efed
MD5 83dbcf9df68865be5a562ba3ca9c27fb
BLAKE2b-256 4c1dfd99aefe873071d68e07a093ad8fece3f592c8127592f287a2053c1c0c0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for nicekit-0.1.0-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