Pre-release · MIT licensed

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 pywrapai

Coming 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.000018
Comparison

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 CloudPyWrapAI
Where it runsTheir serversYour own SQLite, PostgreSQL, or MySQL
Cost attributionAggregate, limitedPer-user, per-session, per-call
Spend limitsNot built inHard USD + context-token caps per agent run
Provider swapA package per providerOne `provider=` argument
Vendor lock-inYesNone — it's your database
BehaviorHidden abstractionsExplicit, visible Python
Feature set

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.

Examples

Templates to build from

Full example apps built with all three libraries — not snippets.

Coming soon

Support Chatbot

PyQt5 desktop app

Login, versioned prompts, live token + cost panel.

Coming soon

RAG Knowledge Assistant

Retrieval-augmented chatbot

Ask questions over your own documents.

Coming soon

Retail Analytics Agent

Flask + ReAct agent

A tool-calling agent over a sales database.

See all templates →

Ready to try it?

Start with the tutorial — a working chatbot in about ten minutes.