skillfed

kosong

The LLM abstraction layer for modern AI agent applications.

kosong v0.56.0 503.2K downloads/30d#6,306 on PyPI
License unclear Active released

What it is and what it does

Kosong is an LLM abstraction layer designed to unify how you interact with multiple large language model providers. It standardizes message structures, handles asynchronous tool orchestration, and lets you swap between providers (Kimi, Anthropic, Google Gemini, OpenAI) without rewriting your agent logic. The package is built on pydantic for schema validation, loguru for logging, and mcp for protocol support, and it exposes a simple async API for chat completion, streaming, and tool calling.

You use it by instantiating a chat provider, building a message history, and calling kosong.generate() or kosong.step() to get responses. Tool calling is handled through a pluggable toolset interface where you define tools as pydantic-based classes. This design avoids vendor lock-in and lets you experiment with different LLM backends without changing application code.

Use it for:

  • Build multi-provider AI agents that can switch between Kimi, Anthropic, Google Gemini, and OpenAI without code changes.
  • Implement tool-calling workflows where the LLM orchestrates function execution asynchronously across a defined toolset.
  • Stream LLM responses in real time while maintaining a unified message history and provider abstraction.
  • Prototype and test agent behavior across different LLM backends to compare cost, latency, and output quality.
  • Standardize message structures and chat logic across multiple projects using a single abstraction layer.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Kosong is an LLM abstraction layer that unifies message structures and asynchronous tool orchestration across multiple chat providers, letting you build AI agents without vendor lock-in.

Yes, with conditions. Kosong is actively maintained and has low install friction, making it a solid choice for building multi-provider AI agents. However, the package is very new (first release 2025-10-15) and has no recorded license metadata—verify the license terms before using in proprietary work, and expect the API to evolve. If you need vendor-agnostic LLM abstraction and are comfortable with a young codebase, it's worth trying.

Install

kosong on PyPI

pip

pip install kosong

uv

uv add kosong

poetry

poetry add kosong

Installing kosong

Before you install

Low install friction with a pure-Python wheel. Active maintenance as of 11 days ago. Requires Python 3.12 or higher and brings in 9 runtime dependencies including anthropic, google-genai, openai, pydantic, and loguru.

License in practice

License treatment is unclear—no SPDX identifier or raw license text is recorded. Verify the actual license before using in proprietary or copyleft-sensitive projects.

Quickstart

import asyncio
import kosong
from kosong.chat_provider.kimi import Kimi
from kosong.message import Message

async def main():
    kimi = Kimi(base_url="...", api_key="...", model="...")
    history = [Message(role="user", content="Who are you?")]
    result = await kosong.generate(chat_provider=kimi, system_prompt="...", tools=[], history=history)
    print(result.message)

asyncio.run(main())

Requires Python 3.12 or higher. API keys for at least one chat provider (Kimi, Anthropic, Google Gemini, or OpenAI) must be configured.

Verify before relying

  • Whether the package is published under an open-source or proprietary license—no license metadata is recorded.
  • Actual test coverage and stability guarantees given the very recent first release (2025-10-15).
  • Whether streaming and tool-calling features are production-ready or still experimental.

Package facts

License not declared (unclear)
Python support supports the current Python release (>=3.12)
Install friction low — pure-Python wheel
Runtime dependencies 9 — anthropic, google-genai, jsonschema, loguru, openai, pydantic, python-dotenv, typing-extensions, mcp
Maintenance actively maintained — 11 days since the last release
First released
Downloads 503,181/month — #6,306 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: kosong-0.56.0-py3-none-any.whl

Tags

llm abstraction layermulti-provider chat apiai agent frameworkasync tool orchestrationvendor-agnostic llm client
llm-abstractionmulti-providerasync-agents

More Artificial Intelligence packages