Skip to main content

Lanternfish docs

Build from first trace to first briefing

Browse documentation

Getting Started

Step 3 of 5

5 min read

Connect your first agent

One call captures your LLM and framework calls. Add your own steps and decisions where you need more detail.

Choose your approach

Start with auto-instrument; add manual steps for the parts of your agent you need to explain.

Auto-instrument (recommended)

The SDK automatically patches OpenAI, Anthropic, and other LLM libraries. No code changes needed — just initialize and run.

1. Initialize with auto-instrument

import os
import lanternfish

# Call once at startup. Installed providers (OpenAI, Anthropic, LangChain, CrewAI…) are traced from here on.
lanternfish.instrument(
    api_key=os.environ["LANTERNFISH_API_KEY"],
    endpoint=os.environ["LANTERNFISH_ENDPOINT"],
    agent="travel-agent",          # shown as the agent name on every run
)

from openai import OpenAI

response = OpenAI().chat.completions.create(   # traced automatically
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
)

What gets captured: Model, tokens, duration, tool calls and errors. Cost is shown for models with a known price. HTTP, SQL and Redis calls are recorded only if you pass include=["http", "sql", "redis"].

Verify your first run

Run your agent once, then open Runs in the sidebar. Spans are sent in the background every few seconds, so the run usually appears within 10 seconds.

The run appears on the Runs page

Its steps are listed when you open the run

Token usage is shown; cost too, if the model's price is known

The agent name matches instrument(agent=...)

Troubleshooting

The run does not appear?
Turn on the SDK log with logging.basicConfig(level="INFO"). It names the endpoint it sends to and logs every rejected batch with the reason: an invalid or revoked key, a reached plan limit, or an unreachable endpoint. Short scripts must call lanternfish.flush() before they exit.
LLM calls are not captured?
Install the extra for your provider, for example pip install "lanternfish[openai]". Without it the SDK skips that provider; the INFO log lists the integrations it turned on.
Will it slow my agent down?
Spans are batched and sent from a background thread, so your agent never waits on the network. HTTP, SQL and Redis calls are not recorded unless you include them, which keeps the volume to your agent's own steps.

Next step

Understand your first Briefing

Once runs arrive, the briefing compares them with the previous period and tells you what changed.

Continue to First Briefing