What you need
- The
aipackage installed (v4, v5, v6, or v7) - A Foglamp API key (starts with
fl_), created in the dashboard or printed by the seed script when self-hosting
Not sure which AI SDK version you have? Run
npm ls ai or check
package.json. There are two setup paths, one for v4 to v6 and one for v7.
Both produce the same traces.1. Install
2. Configure
Set your key in the environment:.env
If
FOGLAMP_API_KEY is not set, Foglamp does nothing: no traces are sent and
nothing breaks. This makes it safe to keep the code in place in every
environment.3. Add it to your code
Pick the tab for your AI SDK version.- AI SDK v4 to v6
- AI SDK v7 (beta)
Wrap the
ai module once with wrap(), then use fog.with(...) to name
your calls. The functions you get back have the AI SDK’s own types, so you
use them exactly as before.wrap() also covers the AI SDK’s agent classes, and fog.run(context, fn)
lets you set context for a whole block of code at once. See
AI SDK v4 to v6 (wrap) for details.4. Flush
On long-running servers (Node, Bun), Foglamp sends data automatically on a timer. In serverless functions, make sure the data is sent before the function returns:5. Look at the dashboard
Run your app, then open the dashboard. Your call shows up under Traces with its spans, tokens, cost, and timing. Calls that share aworkflowRunId appear
together on the Workflows page.
SDK reference
All options and integration fields.
Data model
How traces, spans, workflows, and runs fit together.
.png?fit=max&auto=format&n=1sml0kwCw1BNtiz-&q=85&s=a7c846a133aa3480dc1e03a2da5fec2b)
.png?fit=max&auto=format&n=1sml0kwCw1BNtiz-&q=85&s=6534218552b79980770f11c40aafd6ec)