Shakti — AI-first, async Python web framework. Born in India, built for the world.
Project description
Shakti
📖 Docs: https://shakti.adityabhat.in
An AI-first, async Python web framework.
Born in India. Built for the world.
pip install "shakti-framework[all]"
What is Shakti?
Shakti is a modern Python web framework designed for the AI era. It gives you everything you need to build production-ready APIs — routing, database, auth, AI, background jobs, monitoring — all in a single install, zero configuration.
Features
⚡ Core
- Fully async ASGI — built for speed
- Typed routing with path converters
- Middleware system (CORS, logging, rate limiting)
- Dependency injection
- Layered config (
.env+ YAML + environment variables) - Built-in test client
🗄️ Database
- Async SQLAlchemy ORM
- Auto migrations with Alembic
- Repository pattern (get, filter, create, update, delete)
- Code generation — scaffold models and CRUD in one command
🔐 Auth
- JWT access + refresh tokens
- Role-based access control (RBAC)
- API key authentication
- Password hashing (bcrypt)
- Ready-to-use login, register, logout endpoints
🤖 AI
- Built-in Claude (Anthropic) and OpenAI support
- Chat, completion, and streaming
- RAG (Retrieval-Augmented Generation)
- AI agents with tool calling
- Prompt templates (summarize, translate, extract, review)
🖥️ Admin Panel
- Auto-generated admin UI for any model
- Dark mode and light mode
- Search, pagination, CSV export
- Activity log
- No extra setup needed
🔌 WebSockets
- Real-time connections
- JSON and text messaging
- Path parameters
- AI streaming over WebSocket
📄 Document AI
- PDF text extraction
- Image OCR via Claude Vision
- Document Q&A
- Structured data extraction
- Document classification and summarization
⚙️ Background Jobs
- Async job queue
- Automatic retry with exponential backoff
- Interval scheduling (every X minutes/hours/days)
- Job status tracking
📊 Monitoring
- Live dashboard at
/monitor/ - Health checks (liveness + readiness probes)
- Request metrics (avg, p95, p99 response times)
- CPU, memory, disk usage
- Per-endpoint analytics
- Custom health check hooks
🛠️ Developer Tools
- Rate limiting middleware
- Email sending (SMTP)
- Cache (in-memory + Redis)
- File uploads (multipart)
- OpenAPI + Swagger UI at
/docs - ReDoc at
/redoc
Quick Start
pip install "shakti-framework[all]"
shakti new myapp
cd myapp
shakti run --reload
Open http://127.0.0.1:8000 — your app is running.
60-Second Example
from shakti import Shakti, Depends
from shakti.config import Config
from shakti.orm import Database, Repository
from shakti.auth import Auth
from shakti.auth.models import User
from shakti.ai import AI
from shakti.admin import Admin
from shakti.monitoring import Monitor
from shakti.workflows import WorkflowEngine
from shakti.websocket import WebSocket
config = Config()
app = Shakti(title="My App", config=config)
db = Database(config.require("database.url"))
db.init_app(app)
auth = Auth(db, secret_key=config.require("auth.secret_key"))
auth.init_app(app)
ai = AI(config)
ai.init_app(app)
admin = Admin(db, auth, title="My Admin")
admin.register(User)
admin.init_app(app)
monitor = Monitor()
monitor.init_app(app)
workflows = WorkflowEngine()
workflows.init_app(app)
@app.get("/")
async def index() -> dict:
return {"framework": "Shakti", "status": "running"}
@app.get("/me")
async def me(user: User = Depends(auth.get_current_user())) -> dict:
return user.to_dict()
@app.websocket("/ws/chat")
async def chat(ws: WebSocket) -> None:
await ws.accept()
async for msg in ws.iter_json():
reply = await ai.chat(msg["text"])
await ws.send_json({"reply": reply})
Code Generation
Scaffold a full API with one command:
# Generate model
shakti generate model Post title:str body:text views:int
# Generate model + full CRUD endpoints
shakti generate api Post title:str body:text views:int
# Run migrations
shakti makemigrations "add posts"
shakti migrate
That's it. You now have:
POST /posts— createGET /posts— list allGET /posts/{id}— get onePUT /posts/{id}— updateDELETE /posts/{id}— delete
CLI Reference
shakti new myapp # scaffold project
shakti run --reload # start dev server
shakti generate model Post title:str # generate model
shakti generate crud Post # generate CRUD
shakti generate api Post title:str body:text # model + CRUD
shakti makemigrations "message" # create migration
shakti migrate # apply migrations
shakti db history # migration history
shakti db current # current revision
shakti version # show version
Configuration
# config/settings.yaml
app:
name: myapp
debug: true
database:
url: sqlite+aiosqlite:///./myapp.db
auth:
secret_key: ${SECRET_KEY}
access_token_expire_minutes: 30
ai:
provider: anthropic
model: claude-sonnet-4-6
api_key: ${ANTHROPIC_API_KEY}
system_prompt: "You are a helpful assistant."
mail:
host: smtp.gmail.com
port: 587
username: you@gmail.com
password: ${MAIL_PASSWORD}
# .env
SHAKTI_ENV=development
SECRET_KEY=your-secret-key
ANTHROPIC_API_KEY=your-key
Install Options
pip install shakti-framework # core only
pip install "shakti-framework[server]" # + uvicorn
pip install "shakti-framework[orm]" # + SQLAlchemy + Alembic
pip install "shakti-framework[auth]" # + JWT + bcrypt
pip install "shakti-framework[ai]" # + Claude + OpenAI
pip install "shakti-framework[monitoring]" # + system metrics
pip install "shakti-framework[all]" # everything
Modules
| Module | Import | What it does |
|---|---|---|
| Core | from shakti import Shakti |
Routing, middleware, DI, config |
| ORM | from shakti.orm import Database |
SQLAlchemy async + migrations |
| Auth | from shakti.auth import Auth |
JWT, RBAC, API keys |
| AI | from shakti.ai import AI |
Claude/OpenAI, RAG, agents |
| Admin | from shakti.admin import Admin |
Auto-generated admin panel |
| WebSocket | from shakti.websocket import WebSocket |
Real-time connections |
| Document AI | from shakti.docs import DocumentAI |
PDF, OCR, document Q&A |
| Workflows | from shakti.workflows import WorkflowEngine |
Background jobs |
| Monitoring | from shakti.monitoring import Monitor |
Health checks, metrics |
| Cache | from shakti.cache import Cache |
Memory + Redis caching |
| Mailer | from shakti.mailer import Mailer |
Send emails |
| OpenAPI | from shakti.openapi import OpenAPI |
Swagger UI + ReDoc |
| Rate Limit | from shakti.middleware import RateLimitMiddleware |
Request rate limiting |
Auth Endpoints
Auto-registered when you call auth.init_app(app):
| Method | Route | Description |
|---|---|---|
| POST | /auth/register |
Create account |
| POST | /auth/login |
Login, get tokens |
| POST | /auth/refresh |
Refresh access token |
| POST | /auth/logout |
Logout |
| GET | /auth/me |
Current user info |
AI Endpoints
Auto-registered when you call ai.init_app(app):
| Method | Route | Description |
|---|---|---|
| POST | /ai/chat |
Single or multi-turn chat |
| POST | /ai/complete |
Chat with token counts |
| POST | /ai/stream |
Server-sent events streaming |
| POST | /ai/rag/add |
Add document to RAG store |
| POST | /ai/rag/query |
Ask question with context |
| GET | /ai/info |
Provider and model info |
License
MIT © Aditya Bhat — Born in India 🇮🇳
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shakti_framework-0.2.1.tar.gz.
File metadata
- Download URL: shakti_framework-0.2.1.tar.gz
- Upload date:
- Size: 104.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c3335df8cecb5bec46b8448404025a2b312e990917a92be3ae6465addfec9a5
|
|
| MD5 |
8285aadf668854446b8a54cca478504e
|
|
| BLAKE2b-256 |
2f3130b059b648d936a7b408347b8c9238fee226f69428b8dc06936583f36588
|
File details
Details for the file shakti_framework-0.2.1-py3-none-any.whl.
File metadata
- Download URL: shakti_framework-0.2.1-py3-none-any.whl
- Upload date:
- Size: 105.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7dd1cc5a1eec96795feb261908b5d42e650708710bd360b2ff5b959036b036b
|
|
| MD5 |
b71d744439cfa50a859546e9a5bbe71f
|
|
| BLAKE2b-256 |
99532a64cb807d4069c9a656d820494813c53d62c49435f3d3c7a10061abeae3
|