Overview
The Statsig Node AI SDK lets you manage your prompts, online and offline evals, and debug your LLM applications in production. It depends upon the Statsig Node Server SDK, but provides convenient hooks for AI-specific functionality.1
Install the SDK
2
Initialize the SDK
If you already have a Statsig instance, you can pass it into the SDK. Otherwise, we’ll create an instance for you internally.
- Don't use Statsig
- Already have Statsig instance
Initialize the AI SDK with a Server Secret Key from the Statsig console.
Initializing With Options
Initializing With Options
Optionally, you can configure StatsigOptions and StatsigAI options:
Using the SDK
Getting a Prompt
Statsig can act as the control plane for your LLM prompts, allowing you to version and change them without deploying code. For more information, see the Prompts documentation.Logging Eval Results
When running an online eval, you can log results back to Statsig for analysis. Provide a score between 0 and 1, along with the grader name and any useful metadata (e.g., session IDs). Currently, you must provide the grader manually — future releases will support automated grading options.OpenTelemetry (OTEL)
The AI SDK works with OpenTelemetry for sending telemetry to Statsig. You can either turn on the default OTel integration in theStatsigAIOptions, or set up your own OTel to send traces to Statsig.
More advanced OTel configuration and exporter support are on the way.
Wrapping OpenAI
The Statsig OpenAI Wrapper automatically adds tracing and log events to your OpenAI SDK usage, giving you in-console visibility with minimal setup.AI Options
Options for configuring the AI SDK. Pass these into theStatsigAI constructor. See Initializing with Options.
Configuration Properties
boolean
Enables Statsig’s default OpenTelemetry setup for automatic tracing and instrumentation. Defaults to false.
StatsigTracingConfig
Configuration object for tracing and instrumentation settings.
string
Name of the service for tracing identification. Used in OpenTelemetry spans and traces.
boolean
Enables automatic instrumentation of common libraries and frameworks for tracing. Defaults to false.