Metadata-Version: 2.4
Name: tokenly-cli
Version: 1.1.0
Summary: Tokenly: The Intelligent AI Proxy & Context Compressor
Author-email: Tokenly Team <support@tokenly.ai>
Project-URL: Homepage, https://github.com/skush2024/Tokenly
Project-URL: Bug Tracker, https://github.com/skush2024/Tokenly/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: typer[all]>=0.12.0
Requires-Dist: rich>=13.0.0
Requires-Dist: python-dotenv>=1.0.1
Requires-Dist: httpx>=0.27.0
Requires-Dist: uvicorn>=0.30.0
Requires-Dist: fastapi>=0.111.0
Requires-Dist: litellm>=1.40.0
Requires-Dist: tiktoken>=0.7.0
Requires-Dist: PyYAML>=6.0.1

# 🛸 Tokenly

**The Intelligent AI Proxy & Context Compressor**

Tokenly is a high-performance, developer-first AI proxy designed to slash LLM costs while boosting intelligence. It intelligently routes your queries between local models, free cloud tiers, and premium providers, ensuring you always get the best balance of speed, cost, and reasoning capability.

[![PyPI version](https://img.shields.io/pypi/v/tokenly-cli.svg?color=blue)](https://pypi.org/project/tokenly-cli/)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
[![Docker Required](https://img.shields.io/badge/docker-required-blue.svg)](https://www.docker.com/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

---

## 🌟 Key Features

### 🧠 Smart Multi-Tier Routing
Tokenly analyzes every incoming query's difficulty. Simple tasks are routed to local models ($0 cost), moderate tasks to free tiers (e.g., Gemini), and complex reasoning tasks to premium models (e.g., GPT-4o, Claude 3.5 Sonnet).

### 🗜️ Dynamic Context Compression
Save up to 40% on token usage. Tokenly's core engine identifies redundant context, boilerplate, and noise in your prompts, stripping them away before they reach the LLM—without losing semantic meaning.

### 🏠 Local-First AI (Dockerized)
Comes pre-configured with a lightweight local stack. Tokenly automatically manages a Dockerized Ollama instance running `llama3.2:1b` and `llama3.2:3b` for lightning-fast, private, and free completions.

### 📊 Professional Analytics Dashboard
A stunning, minimalist dashboard inspired by modern design systems. Track your net expenditure, monitor token savings in real-time, and analyze request logs with deep-dive insights.

### 🔌 Seamless IDE Integration
Built specifically for developers. Tokenly integrates directly with [Continue.dev](https://www.continue.dev/), automatically configuring your VS Code or JetBrains environment to use the Tokenly proxy.

---

## 🚀 Quick Start

### 1. Prerequisites
- **Python 3.8+**
- **Docker Desktop** (Running)
- **Continue.dev Extension** (Recommended for VS Code / JetBrains)

### 2. Installation
Install directly via pip:
```bash
pip install tokenly-cli
```

### 3. Setup
Initialize the environment, pull local models, and configure your API keys:
```bash
tokenly setup
```

### 4. Start the Service
Boot the proxy and dashboard in the background:
```bash
tokenly start
```
*Your proxy is now running at `http://localhost:8001/v1` and your dashboard at `http://localhost:8001/dashboard`.*

---

## 💻 CLI Reference

| Command | Description |
| :--- | :--- |
| `tokenly setup` | 🚀 Initialize environment, Docker models, and API keys. |
| `tokenly start` | ⚡ Start the Proxy and Dashboard in the background. |
| `tokenly stop` | 🛑 Gracefully shutdown Proxy and Docker containers. |
| `tokenly status` | 🔍 Check the health of Docker, models, and service. |
| `tokenly dashboard` | 📊 Open the analytics dashboard in your browser. |
| `tokenly logs -f` | 📜 Tail the live activity and routing logs. |
| `tokenly doctor` | 🩺 Run a deep system diagnostic. |
| `tokenly config` | ⚙️  View active configuration and environment variables. |
| `tokenly clear-logs`| 🧹 Wipe the request logs and dashboard data. |
| `tokenly clean` | 🧨 Wipe all local data and configuration (~/.tokenly). |
| `tokenly version` | 🏷️  Show current version. |

---

## 🛠️ Architecture

Tokenly operates as a transparent middleman between your IDE and your AI providers:

1.  **Incoming Request**: Your IDE (via OpenAI-compatible API) sends a request to `localhost:8001`.
2.  **Intelligence Layer**: The Proxy calls the **Core Microservice** which:
    - **Classifies**: Determines query difficulty.
    - **Routes**: Selects the optimal model (Local vs. Cloud).
    - **Compresses**: Optimizes the prompt context.
3.  **Execution**: The Proxy executes the request via **LiteLLM** or **Local Ollama**.
4.  **Analytics**: Metrics are captured asynchronously and pushed to the Dashboard.

---

## 🎨 Tech Stack
- **Backend**: FastAPI, LiteLLM, Typer
- **Core**: Pydantic, Httpx, Python-Dotenv
- **Infrastructure**: Docker, Ollama
- **Frontend**: Vanilla JS, CSS3 (Modern, high-performance UI)

---

## 📝 License
Distributed under the MIT License. See `LICENSE` for more information.

---
*Built with ❤️ for the Developer Community.*
