Skip to main content

A Python SDK for Kimi Agent (Kimi CLI).

Project description

Kimi Agent SDK

Kimi Agent SDK exposes the Kimi CLI agent runtime as a Python library. It provides a high-level prompt API for streaming assistant messages and a low-level Session API for handling Wire messages and approvals yourself.

Installation

Requires Python 3.12 or higher.

uv add kimi-agent-sdk

Examples

High-level prompt

import asyncio
from kimi_agent_sdk import prompt


async def main() -> None:
    async for msg in prompt("Write a hello world program", yolo=True):
        print(msg.extract_text(), end="", flush=True)
    print()


asyncio.run(main())

Manual approval handling (low-level)

import asyncio
from kaos.path import KaosPath
from kimi_agent_sdk import ApprovalRequest, Session, TextPart


async def main() -> None:
    async with await Session.create(work_dir=KaosPath.cwd()) as session:
        async for wire_msg in session.prompt("List files in current directory"):
            match wire_msg:
                case TextPart(text=text):
                    print(text, end="", flush=True)
                case ApprovalRequest() as req:
                    req.resolve("approve")


asyncio.run(main())

Notes

  • prompt() creates a temporary session per call.
  • Session.prompt() yields raw Wire messages and requires handling approvals.
  • work_dir and skills_dir expect KaosPath values.
  • See the API docstrings for more configuration options.

Project details


Download files

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

Source Distribution

kimi_agent_sdk-0.0.3.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

kimi_agent_sdk-0.0.3-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file kimi_agent_sdk-0.0.3.tar.gz.

File metadata

  • Download URL: kimi_agent_sdk-0.0.3.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kimi_agent_sdk-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7433f1f665b9de8b2fbed1c3d52a30c2978da12efbca90fecc862bc718a534e0
MD5 1106dddb739ece529069db395a09078d
BLAKE2b-256 ceeed1b8facbae73317707e46970b03af7601d4caaa8dbf7b625af76b37cbf4f

See more details on using hashes here.

File details

Details for the file kimi_agent_sdk-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: kimi_agent_sdk-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kimi_agent_sdk-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d454a35d53a5b7fc8596f83b2bb2986a7b55a56c9deb83213f72a3fe748a4dfd
MD5 a9ee628c933fde75fbbac2db16bbd70a
BLAKE2b-256 0347e73cb97cbd6ecfe8b43952f2d2781a2b9430030386f62fa33e6c5aa9747c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page