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 kimi_agent_sdk import ApprovalRequest, Session, TextPart


async def main() -> None:
    async with await Session.create(work_dir=".") 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.
  • 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.1.tar.gz (6.2 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.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kimi_agent_sdk-0.0.1.tar.gz
  • Upload date:
  • Size: 6.2 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.1.tar.gz
Algorithm Hash digest
SHA256 59225446d938867dac1ebffa063384568ef91e0d89f1e5d6b6a3184c0249f97d
MD5 9670953b3236d2ff92a68cfda8719e66
BLAKE2b-256 c1a6c40fb8d28bea4f9d468b856b1b7ead04ecb89a980d0008586dbb9db430b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kimi_agent_sdk-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 af2ab0bbe74911b153b0927d9809ced89c4e1b829ec991778beb0529d0a80e03
MD5 e1f684d1df65bf97734dc2a74244a8e1
BLAKE2b-256 c15942983534d468bb947931f63cd51e407cdf2396d3fc0fe5cc016d51f3b6a5

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