Skip to main content

Shakti

Docs PyPI License Tests

📖 Docs: https://shakti.adityabhat.in

An AI-first, async Python web framework.

Born in India. Built for the world.

pip install "shakti-framework[all]"
pip install shakti-framework

PyPI Python License: MIT Tests


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 — create
  • GET /posts — list all
  • GET /posts/{id} — get one
  • PUT /posts/{id} — update
  • DELETE /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 🇮🇳

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shakti_framework-0.2.5.tar.gz (139.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

shakti_framework-0.2.5-py3-none-any.whl (111.4 kB view details)

Uploaded Python 3

File details

Details for the file shakti_framework-0.2.5.tar.gz.

File metadata

  • Download URL: shakti_framework-0.2.5.tar.gz
  • Upload date:
  • Size: 139.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.0

File hashes

Hashes for shakti_framework-0.2.5.tar.gz
Algorithm Hash digest
SHA256 5f4dfad46ab476a05c6d0dbaa70c01977cb3108065d84ee54de067c618562247
MD5 d03aff2f11519a9101c80e4bcb09f686
BLAKE2b-256 6a06a65f60b2cdf4e98d393cf40e622de2185ad9d7976c21bc2bb8b3988fada4

See more details on using hashes here.

File details

Details for the file shakti_framework-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for shakti_framework-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 56ec0bbb79bac7b9d9a792e9b7d5f8f9430801a3d07e250a1e77009bbcb700dd
MD5 bb4f60e7d4892de2b87b6bca94aa4a2d
BLAKE2b-256 f2add445a80c3649490991f1a98678272b140a454d4126f8a116fbb521c77abd

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 Sentry Error logging StatusPage Status page