Skip to main content

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.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zespan-flask 1.2.2
File Size Uploaded
zespan_flask-1.2.2.tar.gz 4.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zespan-flask 1.2.2
File Interpreter ABI Platform
zespan_flask-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.9 kB

Release files / zespan_flask-1.2.2.tar.gz

Download URL zespan_flask-1.2.2.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dd2ed790ea3950f619ed807a36d4f654b86aebd8b07d1485741b8d8d756481ab
BLAKE2b-256 checksum
How to use checksums
64a5ddfc276404be10908fb2ceceaea4dcdf5abd7bdbcb78c064f17bff5078e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.17.0 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.14.2"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.18 30 Sep 2025","python":"3.14.2","system":{"name":"Windows","release":"11"}} HTTPX2/2.4.0

Release files / zespan_flask-1.2.2-py3-none-any.whl

Download URL zespan_flask-1.2.2-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d80600da9760bc40cc83635f773454f346342e91e6a025205894b439b26896f
BLAKE2b-256 checksum
How to use checksums
8ed95492377ee6fa2cc927dd9f25fd4402270de477ab0f573d5f5bff45ca0ca5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.17.0 {"ci":null,"cpu":"AMD64","implementation":{"name":"CPython","version":"3.14.2"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.18 30 Sep 2025","python":"3.14.2","system":{"name":"Windows","release":"11"}} HTTPX2/2.4.0

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page