Call an LLM. Assemble a conversation. Watch it work.
PyWrapAI is a modular, self-hosted Python toolkit for production AI apps. One job per library — swap providers, add history, or add analytics on your own database without ever touching the other two.
pip install pywrapaiComing soon to PyPI. Each library installs separately — add only what you need.
from pywrapai import LLM
llm = LLM(provider="anthropic")
response = llm.chat(
"What is the capital of France?"
)
print(response.content)
# Paris is the capital of France.
print(response.usage.input_tokens)
# 14
print(llm.tokens.total_cost)
# 0.000018Three libraries. One job each.
Use PyWrapAI alone for a single call. Add PyWrapAI-Graph for history, tools, or RAG. Add PyWrapAI-Monitor when you need analytics.
PyWrapAI
One interface for 4 providers, with cost tracking, retries, and caching built in.
Read the reference →Replaces LangGraphPyWrapAI-Graph
Assembles system prompt, history, and RAG context — then runs the tool-calling loop.
Read the reference →Replaces LangfusePyWrapAI-Monitor
Persists history and cost automatically, on SQLite, PostgreSQL, or MySQL — plus a live dashboard.
Read the reference →Own your data. Cap your spend.
Langfuse and LangSmith are capable, widely-used tools — and they're hosted products you pay for. PyWrapAI runs the same job on infrastructure you already own, with per-user cost attribution and spend limits built in from day one.
| LangChain + Langfuse Cloud | PyWrapAI | |
|---|---|---|
| Where it runs | Their servers | Your own SQLite, PostgreSQL, or MySQL |
| Cost attribution | Aggregate, limited | Per-user, per-session, per-call |
| Spend limits | Not built in | Hard USD + context-token caps per agent run |
| Provider swap | A package per provider | One `provider=` argument |
| Vendor lock-in | Yes | None — it's your database |
| Behavior | Hidden abstractions | Explicit, visible Python |
Everything a production LLM app needs
Nothing it doesn’t. Every behavior here is explicit, visible Python.
4 providers, 1 interface
OpenAI, Anthropic, Gemini, Ollama — one class.
Live analytics dashboard
Self-hosted on SQLite, PostgreSQL, or MySQL — no vendor.
Agent budget caps
Hard USD and context-token limits, not just turn count.
Token & cost tracking
Every call recorded. Cost from one price table.
RAG pipeline
Chunk, embed, retrieve — 6 vector store backends.
Structured output
Pydantic-validated JSON, native mode where supported.
Retry + fallback
Jittered backoff on errors, then a full fallback model.
Real concurrent tools
Parallel tool execution via asyncio.to_thread, not fake async.
Typed errors + logging
One except clause instead of five, plus structured logs.
Templates to build from
Full example apps built with all three libraries — not snippets.
Support Chatbot
PyQt5 desktop appLogin, versioned prompts, live token + cost panel.
RAG Knowledge Assistant
Retrieval-augmented chatbotAsk questions over your own documents.
Retail Analytics Agent
Flask + ReAct agentA tool-calling agent over a sales database.
Ready to try it?
Start with the tutorial — a working chatbot in about ten minutes.