zespan-flask
Automatic LLM observability middleware for Flask. Traces every request, LLM call, and custom span with zero code changes for basic usage.
Installation
pip install zespan-flask
Quick Start
from flask import Flask
from zespan_flask import ZespanFlaskExtension, ZespanConfig
app = Flask(__name__)
config = ZespanConfig(api_key="zsp_your_api_key")
ext = ZespanFlaskExtension(app, config)
Every HTTP request is now automatically traced.
Application Factory Pattern
ext = ZespanFlaskExtension()
def create_app():
app = Flask(__name__)
ext.init_app(app)
return app
Trace LLM Calls
from zespan_flask import observe_llm
@observe_llm(model="gpt-4o", provider="openai")
def generate_response(prompt: str):
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": prompt}]
)
return response
Trace Custom Spans
from zespan_flask import observe_span
@observe_span("fetch_context", span_type="retrieval")
def fetch_context(query: str):
return vector_db.search(query)
Set Custom Attributes
from zespan_flask import set_attribute
@app.route("/chat")
def chat():
set_attribute("user.id", current_user.id)
set_attribute("session.id", session.get("id"))
Configuration
| Option | Default | Description |
|---|---|---|
api_key |
required | Zespan API key (zsp_...) |
base_url |
https://api.zespan.com |
API endpoint |
enabled |
True |
Toggle tracing on/off |
sample_rate |
1.0 |
Fraction of requests to trace (0.0–1.0) |
capture_request_body |
False |
Include request body in traces |
capture_response_body |
False |
Include response body in traces |
redact_fields |
["password","token","api_key"] |
Fields redacted automatically |
debug |
False |
Print flush errors to stdout |
Get your API key at zespan.com.
Metadata
Release files for zespan-flask 1.3.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 |
|---|---|---|---|---|
| zespan_flask-1.3.0.tar.gz | 16.2 kB | Without provenance | Details for zespan_flask-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zespan_flask-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for zespan_flask-1.3.0-py3-none-any.whl |
Total release size: 24.8 kB
Release files / zespan_flask-1.3.0.tar.gz
| Download URL | zespan_flask-1.3.0.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7c1a29f7a04985fa2c1b0ff03212ca4336bf273dbe738dc3cd883cbeac032a34
|
|
BLAKE2b-256 checksum How to use checksums |
4f88aebacea7d38dead081f7ef62dfc595a803bfe52f1f314c1664c42cd91dd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.18.2 {"ci":null,"cpu":"arm64","distro":{"name":"macOS","version":"27.0.1"},"implementation":{"name":"CPython","version":"3.12.15"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 3.5.9 29 Sep 2026","python":"3.12.15","system":{"name":"Darwin","release":"27.0.0"}} HTTPX2/2.16.0
|
Release files / zespan_flask-1.3.0-py3-none-any.whl
| Download URL | zespan_flask-1.3.0-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ea0b8521a6ca11ca8cb7fdbe3c25337c7d2571e6692b5cae371654584d3fd78d
|
|
BLAKE2b-256 checksum How to use checksums |
3283d7ceb1a5865a3d52569a8b8f0127fe8ade1697d51de321670319a030a06d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.18.2 {"ci":null,"cpu":"arm64","distro":{"name":"macOS","version":"27.0.1"},"implementation":{"name":"CPython","version":"3.12.15"},"installer":{"name":"hatch","version":"1.18.2"},"openssl_version":"OpenSSL 3.5.9 29 Sep 2026","python":"3.12.15","system":{"name":"Darwin","release":"27.0.0"}} HTTPX2/2.16.0
|
Security for zespan-flask 1.3.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.