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.3.tar.gz (59.8 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.3-py3-none-any.whl (64.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kivi_ai-0.1.3.tar.gz
  • Upload date:
  • Size: 59.8 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.3.tar.gz
Algorithm Hash digest
SHA256 799d7ddd241eef09430b6c7b7aef636a8db7f99d97eb754e633fc211b834947e
MD5 c24ad2e6489769a85bdd4e05f9af15be
BLAKE2b-256 235911e58c43b9215ec22a26d3df19c03d9fa42771ea4deb7665f4decb9ee690

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kivi_ai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 64.9 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bce4ba7e54e2e3c942382895cf35d0a4c70e9220f73db77e9f33dcf56cf54ca3
MD5 93749ac1db069ce210ce11451e97754a
BLAKE2b-256 e44f73cedc2c8c1d4f81ba8afe2ca0648a35a073adc9d5204b01b3214e3f42c3

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