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.2.tar.gz (7.0 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.2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kimi_agent_sdk-0.0.2.tar.gz
  • Upload date:
  • Size: 7.0 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.2.tar.gz
Algorithm Hash digest
SHA256 5e942351f9a15ac779fd91ab83da48ee7d692d274746b4f28c81ffadce5b8d71
MD5 d690fb2ca694a9d7725075afc76b0715
BLAKE2b-256 51107ea0ac831216773a7da8127622f3f1faf2bcc4c01705fe8a018c7a1a0f71

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kimi_agent_sdk-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5513e25b06bb6b8b45076bb04071493560767a3d3febb73aaa005ab550478d46
MD5 b857f51fef57a5ad3f87127a3d0166dc
BLAKE2b-256 ee7f14f12857c1ad3ba3079f86aa55cab3bdbbaf714a94f3df3d06f9af593db0

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