DigitalKin Python SDK
The DigitalKin Python SDK for building and managing modules within the DigitalKin agentic mesh. Create custom Tools and Archetypes that communicate over gRPC, register with a service mesh, and scale independently.
Features
- Async-native gRPC module system — every module is a gRPC server built on
grpciowith full async support - Typed module contracts — Pydantic models for Input, Output, Setup, and Secret schemas with protocol-based trigger dispatch
- Module-to-module communication — tools and archetypes discover each other via the registry and exchange requests over gRPC
- Tool resolution — archetypes dynamically resolve and invoke tool modules at runtime
- Admission queue & backpressure — built-in request admission with configurable concurrency limits
- Healthcheck protocols — automatic ping, services, and status healthcheck triggers registered on every module
- Profiling — optional
[profiling]extra with asyncio-inspector, pyinstrument, viztracer, and yappi - Batched history writes — efficient storage writes for conversation history
- Redis Streams — durable message passing, crash recovery, and reconnection
Installation
# With uv (recommended)
uv add digitalkin
# With pip
pip install digitalkin
Optional extras:
# Async profiling tools
uv add "digitalkin[profiling]"
# uvloop for faster event loop
uv add "digitalkin[performance]"
Quick Start
1. Define your models
from pydantic import BaseModel
from digitalkin.models.module.base_types import DataModel, DataTrigger
class MessageInput(DataTrigger):
protocol: str = "message"
content: str
class InputModel(DataModel[MessageInput]):
root: MessageInput
class MessageOutput(DataTrigger):
protocol: str = "message"
reply: str
class OutputModel(DataModel[MessageOutput]):
root: MessageOutput
2. Create a module and trigger
from digitalkin import ArchetypeModule, ModuleContext, TriggerHandler
from digitalkin.models.module.setup_types import SetupModel
class MyArchetype(ArchetypeModule[InputModel, OutputModel, SetupModel, BaseModel]):
async def initialize(self, context: ModuleContext, setup_data: SetupModel) -> None:
pass
async def cleanup(self, context: ModuleContext) -> None:
pass
@MyArchetype.register
class MessageTrigger(TriggerHandler[InputModel, SetupModel, OutputModel]):
protocol = "message"
input_format = InputModel
output_format = OutputModel
def __init__(self, context: ModuleContext) -> None:
super().__init__(context)
async def handle(
self,
input_data: InputModel,
setup_data: SetupModel,
context: ModuleContext,
) -> None:
output = OutputModel(root=MessageOutput(reply=f"Echo: {input_data.root.content}"))
await self.send_message(context, output)
3. Run the server
import asyncio
from digitalkin.grpc_servers.module_server import ModuleServer
async def main() -> None:
server = ModuleServer(MyArchetype)
await server.start_async()
await server.await_termination()
asyncio.run(main())
Redis Gateway
The embedded gateway enables real-time bidirectional communication between modules via Redis Streams, with crash recovery and horizontal scaling.
- Durable Streaming: Output persisted to Redis Streams — reconnection via
from_seq. - Zero-Copy Proto: Binary proto serialization to Redis — no JSON intermediary.
- Horizontal Scaling: Each module instance embeds its own gateway. Scale by adding replicas behind a load balancer.
Development
Prerequisites
Setup
git clone --recurse-submodules https://github.com/DigitalKin-ai/digitalkin.git
cd digitalkin
task setup-dev
source .venv/bin/activate
Common Tasks
task linter # Format + lint (ruff) + type check (mypy)
task check # Linter + mypy + tests
task run-tests # Run pytest via Docker
task build-package # Build distribution
task bump-version -- patch|minor|major
task docs-serve # Serve docs locally (mkdocs)
task docs-build # Build docs
task generate-certificates # Generate mTLS certs for gRPC
task clean # Remove build artifacts + __pycache__
task clean-all # Above + remove .venv
Publishing Process
- Update code and commit changes (following conventional branch/commit standard).
- Use
task bump-version -- major|minor|patchto commit the new version. - Use GitHub "Create Release" workflow to publish the new version.
- Workflow automatically publishes to Test PyPI and PyPI.
License
This project is licensed under the terms specified in the LICENSE file.
For more information, visit our Documentation or report issues on our Issues page.
Metadata
Release files for digitalkin 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| digitalkin-1.0.4.tar.gz | 329.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| digitalkin-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 769.1 kB
Release files / digitalkin-1.0.4.tar.gz
| Download URL | digitalkin-1.0.4.tar.gz |
|---|---|
| Size | 329.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29611bd90581abd51327f8721d94b17de830defd4c510e5f3fc7b9154ef57156
|
|
BLAKE2b-256 checksum How to use checksums |
cecf897bc58c66816be68d6df44c357683d2a0cad91140402519f30a209e0e0d
|
| 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 Oct 7, 2026.
Transparency logRelease files / digitalkin-1.0.4-py3-none-any.whl
| Download URL | digitalkin-1.0.4-py3-none-any.whl |
|---|---|
| Size | 439.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
208a929200918c903ea1d8ebc8efe283165638195fab334e13fdde7b54fdc9b5
|
|
BLAKE2b-256 checksum How to use checksums |
1acc29b8d648385c5eff445c8424290711c8b2fc9c6e45161d95aa44036a8083
|
| 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 Oct 7, 2026.
Transparency log