Skip to main content

Kivi โ€” Unified AI chat interface. Provider-agnostic streaming chat with tools, sessions, auto-compaction. Supports OpenAI, vLLM, GitHub Copilot SDK, Claude Agent SDK.

Project description

๐Ÿฅ Kivi โ€” Unified AI Chat Interface

PyPI License: MIT Python 3.10+

Provider-agnostic AI chat with token-level streaming, server-side tools, session persistence, and auto-compaction. One beautiful UI, any backend.

โœจ Features

  • ๐Ÿ”€ Provider Switching โ€” Switch between OpenAI, vLLM, Copilot, Claude mid-conversation
  • โšก Token-Level Streaming โ€” Real-time token streaming for all providers (not word-level)
  • ๐Ÿ› ๏ธ Server-Side Tools โ€” bash, read, write, edit, glob, grep, web_search, web_fetch
  • ๐Ÿ’พ Session Persistence โ€” SQLite-backed sessions with full message history
  • ๐Ÿ“ฆ Auto-Compaction โ€” Automatically compacts context at 75% of provider's window
  • ๐ŸŽจ Claude-like UI โ€” Dark/light themes, thinking blocks, tool blocks, markdown, code highlighting, LaTeX, SVG preview
  • ๐Ÿ“Š Token Dashboard โ€” Usage tracking with Plotly charts
  • ๐Ÿ”ง Git Dashboard โ€” Built-in diff viewer, commit & push

๐Ÿš€ Quick Start

pip install kivi-ai
kivi

Open http://localhost:8899 in your browser. That's it.

๐Ÿ“ฆ Install with SDK support

# With GitHub Copilot SDK support
pip install kivi-ai[copilot]

# With Claude Agent SDK support
pip install kivi-ai[claude]

# Everything
pip install kivi-ai[all]

โš™๏ธ Configuration

All configuration via environment variables or CLI flags:

# Set vLLM backend URL
kivi --vllm-url http://your-server:8000

# Custom port
kivi --port 9000

# Or use environment variables
export VLLM_URL=http://your-server:8000
export OPENAI_API_KEY=sk-...
export KIVI_PORT=9000
kivi

CLI Options

kivi                    Start server (default: 0.0.0.0:8899)
kivi --port 9000        Custom port
kivi --host 127.0.0.1   Bind to localhost only
kivi --vllm-url URL     vLLM backend URL
kivi --reload           Dev mode with auto-reload
kivi --help             Show help

๐Ÿ—๏ธ Architecture

kivi_ai/
โ”œโ”€โ”€ core/               # Types, interfaces, registry
โ”‚   โ”œโ”€โ”€ types.py        # Message, StreamChunk, ToolCall, ModelInfo, etc.
โ”‚   โ”œโ”€โ”€ interfaces.py   # BaseProvider ABC, ToolInterface, SessionStore
โ”‚   โ””โ”€โ”€ registry.py     # Provider & tool registry singleton
โ”œโ”€โ”€ providers/          # Provider implementations
โ”‚   โ”œโ”€โ”€ openai_provider.py   # OpenAI & vLLM (OpenAI-compatible)
โ”‚   โ”œโ”€โ”€ copilot_provider.py  # GitHub Copilot SDK
โ”‚   โ”œโ”€โ”€ claude_provider.py   # Claude Agent SDK
โ”‚   โ””โ”€โ”€ config.py            # Context windows, costs, defaults
โ”œโ”€โ”€ streaming/          # Stream processing
โ”‚   โ”œโ”€โ”€ adapter.py      # Normalize streams (filter empty, ensure DONE)
โ”‚   โ””โ”€โ”€ sse.py          # StreamChunk โ†’ SSE text
โ”œโ”€โ”€ sessions/           # Session management
โ”‚   โ”œโ”€โ”€ store.py        # SQLite store (async, WAL mode)
โ”‚   โ”œโ”€โ”€ manager.py      # Session lifecycle & provider switching
โ”‚   โ””โ”€โ”€ compaction.py   # Auto-compact at 75% context window
โ”œโ”€โ”€ tools/              # Server-side tool system
โ”‚   โ””โ”€โ”€ builtins.py     # bash, read, write, edit, glob, grep, web_search, web_fetch
โ”œโ”€โ”€ frontend/
โ”‚   โ””โ”€โ”€ index.html      # Claude-like chat UI (single file)
โ”œโ”€โ”€ server.py           # FastAPI app โ€” unified streaming endpoint
โ””โ”€โ”€ cli.py              # CLI entry point

Key Design Decisions

  • All providers normalize to AsyncIterator[StreamChunk] โ€” single streaming format
  • Sessions are provider-agnostic โ€” switch providers without losing history
  • SQLite with WAL mode + ThreadPoolExecutor โ€” non-blocking async I/O
  • Atomic message sequencing โ€” no race conditions on concurrent writes
  • Single unified endpoint โ€” POST /api/chat/stream handles all providers

๐Ÿ”Œ Providers

Provider Streaming Tools Thinking Backend
vllm โœ… Token โœ… โœ… Local vLLM server
openai โœ… Token โœ… โŒ OpenAI API
copilot โœ… Token โœ… โŒ GitHub Copilot SDK
claude โœ… Token โœ… โœ… Claude Agent SDK
qwen-copilot โœ… Token โœ… โŒ Copilot SDK โ†’ vLLM
qwen-claude โœ… Token โœ… โœ… Claude SDK โ†’ vLLM

๐ŸŒ API

All endpoints under the server:

Method Endpoint Description
POST /api/chat/stream Unified streaming (SSE)
GET /api/sessions List all sessions
POST /api/sessions Create session
GET /api/sessions/:id/messages Get messages
DELETE /api/sessions/:id Delete session
GET /api/providers List providers
GET /api/models/:provider List models
GET /api/tools List available tools
GET /api/usage Token usage stats

๐Ÿ“„ License

MIT โ€” see LICENSE

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

kivi_ai-0.1.1.tar.gz (59.0 kB view details)

Uploaded Source

Built Distribution

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

kivi_ai-0.1.1-py3-none-any.whl (64.1 kB view details)

Uploaded Python 3

File details

Details for the file kivi_ai-0.1.1.tar.gz.

File metadata

  • Download URL: kivi_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 59.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kivi_ai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7e39342b17e42aec4324c629f2fad2660eb12cea05c13a6dcd75e7336c71cc1b
MD5 1738c1ab8db7a13f40384961770d7642
BLAKE2b-256 1b7c7ebbba0f8b43c24a4c1752bf9e8dae037aeefdd5c6131e5a7e2b8633865d

See more details on using hashes here.

File details

Details for the file kivi_ai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: kivi_ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 64.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kivi_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9b8068fb3b3dd02f5d787ba933594e4b585d378779e857beb31a9ecd6dbaa6f9
MD5 2d2a407430c9fb93fd90822ad365159f
BLAKE2b-256 c04a978babe0457265b889b99d2865d7795574ce9c9a7624816e8d9a3ad2ab11

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