Skip to main content

🥝 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

Metadata

Release files for kivi-ai 0.3.19

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kivi-ai 0.3.19
File Size Uploaded
kivi_ai-0.3.19.tar.gz 137.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kivi-ai 0.3.19
File Interpreter ABI Platform
kivi_ai-0.3.19-py3-none-any.whl Python 3 none any Details

Total release size: 297.7 kB

Release files / kivi_ai-0.3.19.tar.gz

Download URL kivi_ai-0.3.19.tar.gz
Size 137.8 kB
Tags Source
SHA-256 checksum
How to use checksums
86b014977b2c1b9363695bb03d5c03303e79fc612231428319405d0ac527fb2c
BLAKE2b-256 checksum
How to use checksums
9f2096c6273e258850e1e11726c7d7fd82bbfada11d7702b0d926930897ba845
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / kivi_ai-0.3.19-py3-none-any.whl

Download URL kivi_ai-0.3.19-py3-none-any.whl
Size 159.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06a45d4802b7b5f392e5230c5c00cac2226781684630a738032c729a295b307a
BLAKE2b-256 checksum
How to use checksums
aaba4d840846eb34e8ef8beb28a6738058152731dd5093eae6939de6dda2c941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.3.19 This release

2 release files

0.3.18

2 release files

0.3.16

2 release files

0.3.15

2 release files

0.3.14

2 release files

0.3.13

2 release files

0.3.12

2 release files

0.3.11

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page