Call an LLM. Assemble a conversation. Watch it work.
PyWrapAI is a modular Python toolkit for production AI apps. One job per library, so swapping providers never touches how history is assembled.
git clone https://github.com/js-deepakgiduthuri/PyWrapAI-library && cd PyWrapAI-library && pip install -e .Not yet published to PyPI — pip install pywrapai is coming with the first tagged release.
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.000018Two libraries. One job each.
Use PyWrapAI alone for a single call. Add PyWrapAI-Graph for history, tools, or RAG.
Why not just use LangChain?
LangChain and LangGraph do the same job with more moving parts. PyWrapAI trims the indirection.
| LangChain + LangGraph | PyWrapAI | |
|---|---|---|
| Composition model | Chains, runnables, graphs | Two plain classes |
| Provider swap | A package per provider | One `provider=` argument |
| Cost tracking | A separate SDK | Built into every call |
| Install footprint | One large package | Only what you need |
| 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.
Token & cost tracking
Every call recorded. Cost from one price table.
Structured output
Pydantic-validated JSON, native mode where supported.
Retry + fallback
Backoff on errors, then a full fallback model.
Response caching
SHA-256 keyed, thread-safe, swappable backend.
Async-first
`achat()` and `astream()` on every method.
RAG pipeline
Chunk, embed, retrieve — 6 store backends.
ReAct agent loop
Tool calls with a configurable turn limit.
Typed errors
One except clause instead of five.
Templates to build from
Full example apps built with PyWrapAI — 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.