Lanternfish Python SDK
Record what your AI agent does: its LLM calls, its own steps, the decisions it makes and the release it runs on. Lanternfish compares those runs over time and tells you what changed.
Built on OpenTelemetry. Works next to an existing OpenTelemetry or Logfire setup.
Install
pip install "lanternfish[openai]"
Use the extra for each provider you call: openai, anthropic, gemini, groq, langchain, crewai,
llamaindex, or all. Requires Python 3.11+.
Start
export LANTERNFISH_API_KEY="lfsk_..." # Settings → API keys
export LANTERNFISH_ENDPOINT="https://your-lanternfish-endpoint"
import lanternfish
lanternfish.instrument(agent="travel-agent")
From here on, calls to installed providers are recorded. The SDK never picks a destination by itself: without an endpoint it stops with an error that says what to set.
Record your own steps and decisions
import lanternfish
@lanternfish.trace # records arguments; capture_args=False for private data
def search_flights(destination: str) -> list[str]:
...
with lanternfish.set_user("user_42", session_id="sess_9"): # removed again when the block ends
with lanternfish.span("book-trip"):
options = search_flights("Lisbon")
with lanternfish.reasoning(name="pick_flight") as r:
r.consider_option("KLM 1724", score=0.8, reason="Arrives before the meeting")
r.decide("KLM 1724", confidence=0.8, reason="Arrives before the meeting")
A step that raises is marked failed, with the exception type and message.
Releases
Every span carries the release it ran on: release= if you pass it, otherwise LANTERNFISH_RELEASE, otherwise the
commit your CI or host exposes (GITHUB_SHA, VERCEL_GIT_COMMIT_SHA, RENDER_GIT_COMMIT, …). To mark the moment a
release went live, call this from your deploy step:
lanternfish.record_deployment("v1.8.2", metadata={"commit": "a1b2c3d", "environment": "production"})
Options
instrument() argument |
If omitted | |
|---|---|---|
api_key |
LANTERNFISH_API_KEY |
Project API key, sent only in the x-api-key header |
endpoint |
LANTERNFISH_ENDPOINT |
Your Lanternfish API base URL |
agent |
— | Agent name on every run |
release |
LANTERNFISH_RELEASE or CI commit |
Version of the running code |
environment |
LANTERNFISH_ENVIRONMENT |
For example production |
include |
[] |
Also record "http", "sql", "redis" calls |
capture_content |
True |
Record prompt and completion text of LLM calls |
What is recorded
- LLM calls: model, tokens, duration, errors and, unless
capture_content=False, the prompt and completion text. - HTTP (only with
include=["http"]): method, host, path and status. Never bodies, headers or query strings. - SQL (only with
include=["sql"]): the statement with literals replaced by?. Never parameter values.
Short scripts and serverless
Spans are sent in the background in batches. Call lanternfish.flush() before a short script or a serverless handler
returns; lanternfish.shutdown() runs on process exit by itself.
Troubleshooting
import logging
logging.basicConfig(level="INFO")
The lanternfish logger names the endpoint, lists the integrations it turned on, and logs every rejected batch with
the reason (invalid key, plan limit reached, endpoint unreachable). Sending never raises into your code; a temporary
error is retried once.
License
MIT
Metadata
Release files for lanternfish 0.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 | |
|---|---|---|---|
| lanternfish-0.3.0.tar.gz | 41.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lanternfish-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 87.9 kB
Release files / lanternfish-0.3.0.tar.gz
| Download URL | lanternfish-0.3.0.tar.gz |
|---|---|
| Size | 41.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f9205dfccda0248dbde442e3695244d59c56cc42cb8990d8340a35645d5ea801
|
|
BLAKE2b-256 checksum How to use checksums |
36dcfb63ca9c3751ea883e7da38e5118325afec0e773cdfce796b3a278ee58a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / lanternfish-0.3.0-py3-none-any.whl
| Download URL | lanternfish-0.3.0-py3-none-any.whl |
|---|---|
| Size | 46.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a31d06796ce01dfcf42f90b935ae2af8df0728b28a1510669041985782091f1b
|
|
BLAKE2b-256 checksum How to use checksums |
44c9973c5e5bf4ebce6f8b3dedd4c919ded4920dc22110148b96b19833670118
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency log