Skip to main content

What you need

  • The ai package 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.
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:
See Runtimes and flushing for what each platform needs.

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 a workflowRunId appear together on the Workflows page.

SDK reference

All options and integration fields.

Data model

How traces, spans, workflows, and runs fit together.