Quickstart
This guide will get you from zero to traced AI calls in under 5 minutes.Prerequisites
- A Foil account (sign up here)
- An API key from the Foil dashboard
- Node.js 18+ or Python 3.8+
Option A: Use the Foil Wizard (Recommended)
The fastest way to integrate. The Foil Wizard is an AI agent that scans your codebase and automatically adds Foil instrumentation.The wizard edits your source files. We recommend running it on a separate branch.
Wizard Documentation
Full guide on what the wizard instruments, troubleshooting, and rate limits
Option B: Manual Integration
Prefer to wire things up yourself? Follow the steps below.Step 1: Install the SDK
- JavaScript
- Python
Step 2: Initialize Foil
- JavaScript
- JavaScript (Auto-Instrumentation)
- Python
The primary SDK — works with any LLM provider and gives you nested span trees.
Step 3: Trace Your First Call
- JavaScript
- JavaScript (Auto-Instrumentation)
- Python
Use
foil.trace() and ctx.llmCall() for full control over your span tree.Step 4: View Your Trace
- Go to the Foil Dashboard
- Navigate to Traces
- Click on your trace to see the full span details
- The input and output of your LLM call
- Token usage breakdown
- Latency metrics
- Any errors or warnings
What’s Next?
Foil Wizard
AI-powered automatic instrumentation
JavaScript SDK
Nested spans, tools, signals, and feedback
Auto-Instrumentation
Zero-code tracing for supported providers
Set Up Alerts
Get notified when issues occur
Record Feedback
Capture user feedback on your AI outputs
Complete Example
Here’s a full working example with an agentic tool-calling loop — the LLM decides which tools to call:- JavaScript
- Python