Praixis Engine — Python Client
A lightweight Python client for the Praixis Engine API, in both sync and async flavors.
PraixisClient— synchronous, zero dependencies, built entirely on the standard library (urllib,json,uuid), so an upstream package release can never break it.AsyncPraixisClient— async/await, built onhttpx(the only optional dependency). Imported lazily, so the sync client stays dependency-free.- Same surface in both: resource-grouped
client.chatandclient.rag— chat- file summary, and RAG ingest/ask/search/embed/compare.
The companion Node.js client lives in its own repository.
Installation
pip install praixis # sync client only, zero dependencies
pip install "praixis[async]" # also installs httpx for the async client
Or vendor the praixis/ package directly into your project — the sync client
has no deps.
Requires Python 3.10+.
Authentication
Every endpoint uses an app-level API key sent as the X-API-Key header.
from praixis import PraixisClient
client = PraixisClient("http://localhost:8080", "your-api-key")
Admin/system routes (
/api/system/*, HTTP Basic auth) are intentionally not part of this SDK. They already have a browser UI, and baking admin credentials into application code would be a security anti-pattern. TheX-API-Keythis SDK uses is an app-level credential, not an admin one.
Chat
# Start a conversation
reply = client.chat.send("Hello, world!")
print(reply["session_id"], reply["content"])
# Continue it
client.chat.send("And again?", session_id=reply["session_id"])
# JSON-mode response, custom system prompt. "content" is still a string — the
# model's raw JSON text — which you parse yourself.
import json
r = client.chat.send("List 3 colors", response_format="json", system_prompt="Be terse")
colors = json.loads(r["content"])
# Sessions
client.chat.list_sessions() # -> [session_id, ...]
client.chat.get_history(session_id) # -> {"session_id", "history": [...]}
client.chat.clear_history(session_id)
# Per-session token usage. Counts the streamed answers (chat and RAG), RAG query
# reformulation, and compaction calls; counters expire with the session.
# estimated_context_tokens shows how close the session is to auto-compacting.
usage = client.chat.get_usage(session_id)
# -> {"session_id", "requests", "prompt_tokens", "completion_tokens",
# "total_tokens", "estimated_context_tokens"}
# Compact a session on demand: fold older exchanges into an LLM-written summary
# (the server also does this automatically near its context budget). Raises
# APIError 400 when there's nothing to fold yet.
client.chat.compact(session_id)
# -> {"status", "session_id", "messages_before", "messages_after",
# "estimated_tokens_before", "estimated_tokens_after"}
# Undo the last exchange: removes the most recent user message and the assistant
# reply that followed it, so you can retry or regenerate. Compaction summaries
# are kept. Raises APIError 400 when there's no user message left to undo.
undone = client.chat.undo_last_exchange(session_id)
# -> {"status", "session_id", "removed_messages", "undone_prompt",
# "messages_remaining"} — undone_prompt is the removed user message
# Summarize an uploaded file (path, or (filename, content[, content_type])).
# Give the filename a .pdf/.docx/.txt extension — it's the primary format
# signal; content_type is only the fallback for extension-less names.
client.chat.summarize_file("report.pdf")
client.chat.summarize_file(("notes.txt", "raw text here"))
Streaming
The server's generative endpoints accept a stream toggle. The buffered methods
(send, ask, summarize_file, compare, summarize_document) send
stream=false and return the server's native JSON — the right default for
scripts and backends. The answer is always under content: chat.send returns
{"session_id", "content"}, rag.ask returns {"session_id", "search_query", "sources", "content"}, and compare / summarize_document / summarize_file
return {..., "content"}.
For token-by-token output, use the streaming variants, which return an iterator
of {"type", "value"} events. Marker events (session_id, model,
search_query, sources, file, progress, error) arrive before the
token events that carry content:
for event in client.chat.stream("Tell me a story"):
if event["type"] == "token":
print(event["value"], end="", flush=True)
elif event["type"] == "session_id":
session_id = event["value"]
# Every buffered generative method has a streaming sibling:
# client.rag.ask_stream(question, collection_name=...) # session_id, search_query, sources, then tokens
# client.chat.summarize_file_stream(file) # file, [progress...], then tokens
# client.rag.compare_stream(coll, f1, f2) # tokens
# client.rag.summarize_document_stream(coll, filename) # file, then tokens
On the async client the same methods yield events with async for:
async for event in client.chat.stream("Tell me a story"):
if event["type"] == "token":
print(event["value"], end="", flush=True)
The request is sent on the first iteration, so connection and HTTP errors
surface there. On the sync client the configured timeout bounds each read
(an idle limit), not the stream's total duration.
Choosing a model
A server may have several LLMs configured. Ask which ones your key may use:
listing = client.models.list()
# {"models": [{"id": "fast", "context_window": 8192},
# {"id": "smart", "context_window": 32768}],
# "default": "fast"}
Then pass model= to any generating method — chat.send, chat.stream,
chat.summarize_file, rag.ask, rag.compare, rag.summarize_document, and
their streaming siblings:
reply = client.chat.send("Explain this contract clause", model="smart")
print(reply["model"]) # "smart" — which model actually answered
Notes worth knowing:
- Omit it and the server decides. Each API key has a default; without one,
the server's registry default answers. A single-model deployment reports one
entry (usually
"default") and never needs the argument at all. - Sessions are sticky. A session remembers the model it was last given, so
passing
model=once keeps the rest of that conversation on it. Passing a different one mid-conversation re-binds it. - Ids are validated. An id your key may not use is rejected with a 400 — identically to one that does not exist, so listing is the way to discover them.
- Streaming reports it too, as a
modelevent right aftersession_id. - Context windows differ.
context_windowis the token budget the server measures a session against before compacting it; moving a long conversation to a smaller model is what that field is there to warn you about.
Requires engine 2.4.0 or newer. Against an older server models.list() returns
404 and model= is ignored.
RAG
# Ingest one or many documents into a collection
client.rag.upload("manual.pdf", collection_name="docs")
client.rag.upload([("a.txt", "..."), ("b.txt", "...")], collection_name="docs")
# Improved search: generate hypothetical questions in the background so plain,
# conversational queries match formal/technical text better. The document is
# searchable immediately; matching improves once generation finishes.
client.rag.upload("ley.pdf", collection_name="docs", improved_search=True)
# Ingest raw text directly — no file wrapping. Same pipeline and options as
# upload; the filename becomes the document's stored identity.
client.rag.upload_text("full document text…", "faq-2026.txt", collection_name="docs")
# -> {"status", "collection_name", "filename", "chunks_stored", "improved_search"}
File inputs. Each file may be a path, a
(filename, content)pair, or a(filename, content, content_type)triple. The filename is the document's stored identity and the server's primary format signal, so prefer a.docx/.txtextension. For extension-less names the server falls back to the declared content type (inferred from the extension when omitted), then to the file's magic bytes.
# Ask a question grounded in a collection
ans = client.rag.ask("What does the manual say about setup?", collection_name="docs")
print(ans["content"], ans["sources"], ans["search_query"])
# Restrict retrieval to one source document. Only the "source" key is honored;
# any other keys are ignored (not an error).
client.rag.ask("What is the notice period?", collection_name="docs",
metadata_filter={"source": "policy.pdf"})
# Retrieval only: ranked raw chunks, no LLM. Pass a standalone query (not reformulated).
hits = client.rag.search("setup steps", collection_name="docs")
for r in hits["results"]:
print(r["source"], r["score"], r["text"]) # hits["score_type"] is "rrf" or "similarity"
# Embeddings, listing, deletion, compare, summarize. compare/summarize_document
# return {..., "content"} and accept an optional response_format.
client.rag.embed("some text")
client.rag.list_collections()
client.rag.list_files("docs")
client.rag.delete_file("docs", "a.txt")
client.rag.delete_collection("docs")
client.rag.compare("docs", "a.txt", "b.txt") # -> {"file_1", "file_2", "content"}
client.rag.summarize_document("docs", "manual.pdf") # -> {"filename", "content"}
# Inspect how a document was chunked — exactly what retrieval sees.
ch = client.rag.get_chunks("docs", "manual.pdf")
# -> {"status", "collection_name", "filename", "total_chunks",
# "chunks": [{"chunk_index", "content"}, ...]}
# Question-index management: improved_search is no longer locked in at upload.
# regenerate_questions rebuilds the index in the background, replacing the old
# questions only once the new pass succeeds; poll question_status until
# generation_pending is False. Raises APIError 409 while a pass is already
# running, 400 when indexing is disabled server-side.
client.rag.regenerate_questions("docs", "manual.pdf")
# -> {"status": "scheduled", "collection_name", "filename", "chunks"}
client.rag.question_status("docs", "manual.pdf")
# -> {"collection_name", "filename", "total_chunks", "questions_stored",
# "generation_pending"}
Error handling
from praixis import (
APIError, AuthenticationError, NotFoundError,
RateLimitError, APIConnectionError,
)
try:
client.chat.send("hi")
except AuthenticationError:
... # 401 / 403
except NotFoundError:
... # 404
except RateLimitError:
... # 429 (per-route limits)
except APIError as e:
print(e.status_code, e.detail)
except APIConnectionError:
... # never reached the server
All exceptions inherit from praixis.PraixisError.
Testing
Both suites run against a standard-library mock HTTP server — no network needed.
# Sync client — zero dependencies
uv run --no-project python tests/test_client.py
# Async client — needs httpx
uv run --with httpx python tests/test_async_client.py
The async suite also asserts that the sync and async resources expose an identical set of methods, so the two clients can't silently drift apart.
Privacy note
This client transmits whatever you pass to it (prompts, documents, session IDs) to the configured Praixis Engine server. Those payloads may contain personal data — handle them according to your own privacy obligations. The client stores nothing locally and adds no telemetry.
License
MIT — see LICENSE.
Metadata
Release files for praixis 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| praixis-1.4.0.tar.gz | 34.5 kB | Without provenance | Details for praixis-1.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| praixis-1.4.0-py3-none-any.whl | Python 3 | none | any | Details for praixis-1.4.0-py3-none-any.whl |
Total release size: 70.5 kB
Release files / praixis-1.4.0.tar.gz
| Download URL | praixis-1.4.0.tar.gz |
|---|---|
| Size | 34.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0be52441979e44cf90d7306c6786e659a1ae96e8d8619243a5f6367112c31904
|
|
BLAKE2b-256 checksum How to use checksums |
27cd99b0f5f44ba56a5facf1242dd07cd91e737aa3b2d67469016c37eea1f6bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / praixis-1.4.0-py3-none-any.whl
| Download URL | praixis-1.4.0-py3-none-any.whl |
|---|---|
| Size | 36.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6ebffcd70ce02aa63f6a800eb66884209d7725c6575fdb882644cd769d7c487
|
|
BLAKE2b-256 checksum How to use checksums |
6eeedce5ce0e8b37c3989831bfc12de43348577eb5e980f5343b6aa6949203ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for praixis 1.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.