Metadata-Version: 2.4
Name: tokenly-cli
Version: 1.0.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, local-first AI proxy designed to slash LLM costs while boosting efficiency. 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 intelligence.

[![Python 3.10+](https://img.shields.io/badge/python-3.10+-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.10+**
- **Docker Desktop** (Running)
- **Continue.dev Extension** (Recommended)

### 2. Installation
Install directly via pip:
```bash
pip install tokenly-cli
```
*Note: If installing from source, use `pip install .` in the root directory.*

### 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`.*

---

## 🛠️ 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.

---

## 💻 CLI Reference

| Command | Description |
| :--- | :--- |
| `tokenly setup` | Initialize environment, Docker models, and API keys. |
| `tokenly start` | Start the Proxy and Dashboard in background mode. |
| `tokenly stop` | Gracefully shutdown Proxy and Docker containers. |
| `tokenly status` | Check the health of Docker, models, and service. |
| `tokenly logs -f` | Tail the live activity and routing logs. |
| `tokenly clean` | Wipe all local data and configuration (~/.tokenly). |

---

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

---

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

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