Overview
The init() function initializes the ZeroEval SDK with your API credentials and configuration options. You must call this function before using any other SDK features.
import * as ze from 'zeroeval' ;
ze . init ({
apiKey: 'your-api-key' ,
workspaceName: 'My Project'
});
Function Signature
function init ( opts ?: InitOptions ) : void
Parameters
Configuration options for the SDK Your ZeroEval API key. If not provided, the SDK will read from the ZEROEVAL_API_KEY environment variable.
The ZeroEval API URL. Defaults to https://api.zeroeval.com. Override this for self-hosted instances.
workspaceName
string
default: "Personal Workspace"
The name of your workspace. This helps organize traces and spans in the ZeroEval dashboard.
How often to flush spans to the backend, in seconds. Default is 10 seconds.
Maximum number of spans to buffer before triggering an automatic flush. Default is 100 spans.
Whether to collect code-level details like function names and line numbers in traces.
Enable or disable specific integrations. By default, all available integrations are auto-detected and enabled. integrations : {
openai : true ,
langchain : false
}
Enable debug logging. You can also enable debug mode by setting the ZEROEVAL_DEBUG=true environment variable.
Returns
This function does not return a value.
Examples
Basic initialization
import * as ze from 'zeroeval' ;
ze . init ({
apiKey: process . env . ZEROEVAL_API_KEY
});
Custom configuration
ze . init ({
apiKey: 'your-api-key' ,
workspaceName: 'Production' ,
flushInterval: 5 , // Flush every 5 seconds
maxSpans: 200 , // Buffer up to 200 spans
debug: true // Enable debug logging
});
Using environment variables
// Set ZEROEVAL_API_KEY and ZEROEVAL_WORKSPACE_NAME in your environment
ze . init ();
Helper Functions
isInitialized()
Check if the SDK has been initialized.
function isInitialized () : boolean
Example:
if ( ! ze . isInitialized ()) {
ze . init ({ apiKey: process . env . ZEROEVAL_API_KEY });
}
validateInit()
Validate that the SDK has been properly initialized with required credentials. Returns false and logs an error if the API key or workspace name is missing.
function validateInit () : boolean
Example:
if ( ! ze . validateInit ()) {
throw new Error ( 'ZeroEval SDK not properly initialized' );
}
Environment Variables
You can configure the SDK using environment variables instead of passing options to init():
ZEROEVAL_API_KEY - Your API key
ZEROEVAL_API_URL - Custom API URL (defaults to https://api.zeroeval.com)
ZEROEVAL_WORKSPACE_NAME - Workspace name
ZEROEVAL_DEBUG - Set to true to enable debug logging
Notes
You should call init() once at the start of your application, before using any tracing features
The SDK automatically sets up integrations for OpenAI, Vercel AI SDK, and LangChain if they are installed
In debug mode, the SDK logs all configuration values (with API key masked) to help troubleshoot setup issues