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

Uploaded Python 3

File details

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

File metadata

  • Download URL: kivi_ai-0.1.7.tar.gz
  • Upload date:
  • Size: 61.6 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.7.tar.gz
Algorithm Hash digest
SHA256 f857c52f9ddf34f58350df03026115791b227b5397dd7e2af42a6662522bfb70
MD5 75364b924dc03ce27175315fc6934ea0
BLAKE2b-256 13cb6e97df9a6a48bbdd6b7e8c5f839e0e064e73cc3b221d4ddc7a25fe31902d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kivi_ai-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 66.7 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9d45b21311ffb6f8eb2f9e438501608b2142f5f099a69bd3b6c12b61ae6f75d5
MD5 bdfc2aa2eba14f6a7585bfbe5d2106ed
BLAKE2b-256 424a547fb3444117a4038c4594b16084fe0411c5554892db823bb52169171506

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