Skip to main content

Kimi Agent Module API

The stable, host-independent contracts for building Kimi application modules: separately installed packages that add commands, LLM tools, background jobs, event handlers, per-guild settings, and durable data to a Kimi deployment.

This package contains no bot runtime, Discord client, database implementation, or module loader. It exports:

  • ModuleSpec, ModuleLoadContext, ModuleRuntimeContext: the declaration a module publishes and the two contexts the host hands it.
  • kimi_agent_module_api.contracts: every runtime port as a typing.Protocol (storage, scheduler, events, Discord actions, interactions, HTTP, services, trust, proposals, health) plus the validators the host runs at preflight.
  • kimi_agent_module_api.events: the normalized discord.* event payloads.
  • kimi_agent_module_api.files: ToolFiles, ToolAttachment, ToolFile, and FileAccessError for invocation-scoped attachment and workspace reads.
  • kimi_agent_module_api.testing: a fake for every port, load_context() for exercising create(), and MemoryStorage (install the testing extra) so a module can unit test itself with only this package installed.

A module exposes a ModuleSpec through the kimi_agent.modules entry-point group:

[project]
dependencies = ["kimi-agent-module-api>=2,<3"]

[project.entry-points."kimi_agent.modules"]
my_module = "my_module_package:SPEC"

The source must pin the API contract it implements when constructing the specification:

from kimi_agent_module_api import ModuleSpec

SPEC = ModuleSpec(
    name="my_module",
    version="0.1.0",
    create=create,
    api_version=2,
)

api_version is a required keyword. Keep it as a literal rather than deriving it from the installed SDK's MODULE_API_VERSION; unchanged module source must not silently claim compatibility merely because it was rebuilt with a newer SDK.

The module guide documents installation, declarations, lifecycle, and every runtime port. The reference module is a complete, commented example that exercises most ports; start there.

Modules using guild-scoped live command replacement through InteractionRouter.replace_guild_commands() should require the host capability discord.guild_commands.v1.

The SDK provides typed modal forms and a narrow Components V2 layout model. Once a response uses that layout model, Discord requires every later edit of the same message to remain a layout. Modules using them should require discord.modals.v1 and/or discord.components_v2.v1.

Message-deletion events include cached author classification: MessageDeleteEvent.author_is_bot and MessageBulkDeleteEvent.bot_message_ids. The values remain unknown for messages that were absent from Discord's cache.

SDK 2.1 adds ModuleToolContext.trigger_discord_message_id. SDK 2.3 adds trigger_discord_message_snapshot, an immutable host-owned capture of the message, guild, channel, author, content, and bot status made at turn entry. Mention-path tool calls receive both; personal and non-message surfaces receive None. Modules that need authoritative evidence from the triggering message should require kimi-agent-module-api>=2.3,<3 and use the snapshot instead of re-fetching mutable or deletable Discord state.

Modules use namespaced guild documents and the physical table names returned by ctx.storage.table().

SDK 2.2 adds optional ModuleToolContext.files. Declare ModulePermissions(tool_files=True), depend on kimi-agent-module-api>=2.2,<3, and require tools.files.v1 in ModuleSpec.requires_capabilities. Existing modules keep api_version=2 and receive files=None without the permission. ctx.files.attachments lists admitted current/reply entries; read_attachment(id, max_bytes=...) and read_workspace(path, max_bytes=...) return bounded bytes without network downloads. The reader expires when the handler returns and is scoped to the actual caller. testing.FakeToolFiles supports independent tests. Module ctx.http methods apply an 8 MiB host ceiling even when callers supply max_bytes; download buffers and validates the bounded response before yielding chunks so connections are released on early consumer exit. See the file access guide for moderation, reply-image availability, privacy, and limits.

Testing the SDK

From this package directory, run its tests without installing the Kimi application:

uv run --isolated --group test python -m pytest -q

Metadata

Release files for kimi-agent-module-api 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kimi-agent-module-api 2.3.0
File Size Uploaded Provenance Actions
kimi_agent_module_api-2.3.0.tar.gz 41.7 kB Without provenance Details for kimi_agent_module_api-2.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kimi-agent-module-api 2.3.0
File Interpreter ABI Platform Actions
kimi_agent_module_api-2.3.0-py3-none-any.whl Python 3 none any Details for kimi_agent_module_api-2.3.0-py3-none-any.whl

Total release size: 80.4 kB

Release files / kimi_agent_module_api-2.3.0.tar.gz

Download URL kimi_agent_module_api-2.3.0.tar.gz
Size 41.7 kB
Tags Source
SHA-256 checksum
How to use checksums
38f45db74b21f379944d4574673e1d51ee20b6693ab3b48ee86ea4199b58c5b2
BLAKE2b-256 checksum
How to use checksums
cfefaba6804f42129a9df1990c4b57320e927c0713aebd424d1819b47c807b80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / kimi_agent_module_api-2.3.0-py3-none-any.whl

Download URL kimi_agent_module_api-2.3.0-py3-none-any.whl
Size 38.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab046f3c2460879d656a02485e338b44b01e4b89ae260cf52b70a037867bbecc
BLAKE2b-256 checksum
How to use checksums
cd1c05e3746a14d2f135df5229d7f3bcd226a4ef25acdd04f65c2dce1c2e97f4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for kimi-agent-module-api 2.3.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page