Install the Lanternfish SDK
Add Lanternfish to your project in under 2 minutes. One call records your agent's LLM and framework calls and sends each run to your project.
Prerequisites
- Python 3.11 or higher
- A Lanternfish workspace (sign up on the free plan)
- An API key and endpoint from Settings → API keys
- Outbound HTTPS from your app to the Lanternfish endpoint
Installation
$ pip install "lanternfish[openai]"Requires Python 3.11 or higher. Replace openai with the provider you use (anthropic, gemini, langchain, …) or use lanternfish[all].
Environment Setup
Store your API key and endpoint as environment variables. Never hardcode the key in source code.
export LANTERNFISH_API_KEY="lfsk_your_key_here"
export LANTERNFISH_ENDPOINT="https://your-lanternfish-endpoint"Pro tip: Add this to your .env file and load it with python-dotenv.
Verify Installation
Confirm the SDK is installed correctly by checking its version:
python -c "import lanternfish; print(lanternfish.__version__)"You should see a version number like 0.3.0. If you get an error, see Troubleshooting below.
Quick Start (30 seconds)
Call instrument() once at your agent's entry point. Every provider you installed an extra for is traced from then on.
import lanternfish
import os
lanternfish.instrument(
api_key=os.environ["LANTERNFISH_API_KEY"],
endpoint=os.environ["LANTERNFISH_ENDPOINT"],
agent="my-agent", # the name shown on every run
)
# Your agent code runs here; calls to installed providers are traced automatically.
# Short scripts: call lanternfish.flush() before they exit.What happens next? The run appears on the Runs page within about 10 seconds, and the Briefing starts comparing your runs with the previous period. Add another extra any time you start using a new provider.
Troubleshooting
ModuleNotFoundError: No module named 'lanternfish'
Make sure you activated your virtual environment: `source venv/bin/activate` (macOS/Linux) or `venv\Scripts\activate` (Windows). If it persists, reinstall with `pip install -U lanternfish` inside that environment.
The log says the API key is invalid or revoked (401)
Check that the whole key was copied: Cloud keys start with `lfsk_`, self-hosted keys with `lflocal_`. A revoked key stops working at once; create a new one at Settings → API keys.
The run does not appear
Spans are sent in the background every few seconds; a script that exits first must call `lanternfish.flush()`. Turn on the SDK log with `logging.basicConfig(level="INFO")`: it names the endpoint and logs every rejected batch with its reason.
LLM calls are not captured
Install the extra for your provider, for example `pip install "lanternfish[openai]"`. The INFO log lists the integrations that were turned on; a provider without its extra is skipped.