Skip to main content

zespan-fastapi

Automatic LLM observability middleware for FastAPI. Traces every request, LLM call, and custom span with zero code changes for basic usage.

Installation

pip install zespan-fastapi

Quick Start

from fastapi import FastAPI
from zespan_fastapi import ZespanFastAPIMiddleware, ZespanConfig

app = FastAPI()

config = ZespanConfig(api_key="zsp_your_api_key")
app.add_middleware(ZespanFastAPIMiddleware, config=config)

Every HTTP request is now automatically traced.

Trace LLM Calls

from zespan_fastapi import observe_llm

@observe_llm(model="gpt-4o", provider="openai")
async def generate_response(prompt: str):
    response = await openai.chat.completions.create(
        model="gpt-4o",
        messages=[{"role": "user", "content": prompt}]
    )
    return response

Trace Custom Spans

from zespan_fastapi import observe_span

@observe_span("fetch_context", span_type="retrieval")
async def fetch_context(query: str):
    return await vector_db.search(query)

Set Custom Attributes

from zespan_fastapi import set_attribute

@app.post("/chat")
async def chat(request: ChatRequest):
    set_attribute("user.id", request.user_id)
    set_attribute("model", request.model)

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-fastapi 1.3.0

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-fastapi 1.3.0
File Size Uploaded Provenance Actions
zespan_fastapi-1.3.0.tar.gz 13.9 kB Without provenance Details for zespan_fastapi-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zespan-fastapi 1.3.0
File Interpreter ABI Platform Actions
zespan_fastapi-1.3.0-py3-none-any.whl Python 3 none any Details for zespan_fastapi-1.3.0-py3-none-any.whl

Total release size: 21.5 kB

Release files / zespan_fastapi-1.3.0.tar.gz

Download URL zespan_fastapi-1.3.0.tar.gz
Size 13.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c3109de366abc6aadaabf0b666abeffde74be99b5df4711561404ec3fc5927e2
BLAKE2b-256 checksum
How to use checksums
1c40f6defc19584a86462788f7f77af4448c817164b15866fa582dd96fba96f5
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_fastapi-1.3.0-py3-none-any.whl

Download URL zespan_fastapi-1.3.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
93d77c899151e3e0735c633ae754a79cdcc742627d34354444796bb7eec1422a
BLAKE2b-256 checksum
How to use checksums
39725b0ea8260bfa831838f4527fbefbc50194745a41d2d9b732632905af2094
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-fastapi 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.

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