JavaScript SDK
Installation
The lunary
module is lightweight and works with Node JS, Deno, Cloudflare Workers, Vercel Edge functions and even Bun.
Node
npm install lunary
Deno
import lunary from "https://esm.sh/lunary"
Setup
Start by importing the lunary
module:
import lunary from "lunary"
If you're using in the browser, import like this:
import lunary from "lunary/browser"
Then initialize the module with your unique app ID.
Option 1: Automatic using environment variables (recommended):
LUNARY_PUBLIC_KEY="PUBLIC KEY"
Option 2: Manually using the .init
method:
// Initialize the Lunary module with your unique app IDlunary.init({appId: "PUBLIC KEY",})
The .init
method accepts the following arguments:
{"appId": string, // Your unique app ID obtained from the dashboard"apiUrl": string, // Optional: Use a custom endpoint if you're self-hosting (you can also set LUNARY_API_URL)"verbose": boolean // Optional: Enable verbose logging for debugging}
LangChain
Usage with LangChain JS.
OpenAI
Automatically track your OpenAI calls.
User Tracking
Identify your users.
Tagging
Segment your queries with tags.
Chats
Record user interactions with your chatbot.
Manual Integration
Learn how to use .trackEvent()
Serverless
Use with Lambda, Cloudflare Workers, Edge Functions, etc.
Agents & Tools
Setup tracing by tracking agents & tools
API Reference
Full list of methods and classes.
Examples
Find examples of usage on GitHub.