Authentication methods
There are two ways to provide your API key to the SDK:Environment variable (recommended)
Set theZEROEVAL_API_KEY environment variable before running your application:
Auto-initialization happens when the first span is created and
ZEROEVAL_API_KEY is present in the environment.Programmatic initialization
Alternatively, you can pass the API key directly when callingze.init():
Configuration options
Theinit() function accepts several configuration options:
Configuration details
apiKey
apiKey
Your ZeroEval API key. Required unless set via
ZEROEVAL_API_KEY environment variable.Type: stringEnvironment variable: ZEROEVAL_API_KEYapiUrl
apiUrl
The URL of the ZeroEval API endpoint. Only change this if you’re using a self-hosted instance.Type:
stringDefault: "https://api.zeroeval.com"Environment variable: ZEROEVAL_API_URLworkspaceName
workspaceName
The name of your workspace. This helps organize traces in the dashboard.Type:
stringDefault: "Personal Workspace"Environment variable: ZEROEVAL_WORKSPACE_NAMEflushInterval
flushInterval
How often (in seconds) to flush buffered spans to the API.Type:
numberDefault: 10 (seconds)maxSpans
maxSpans
Maximum number of spans to buffer before forcing a flush.Type:
numberDefault: 100collectCodeDetails
collectCodeDetails
Whether to collect code details like file paths and line numbers for spans.Type:
booleanDefault: truedebug
debug
Enable debug logging to see detailed SDK operation logs.Type:
booleanDefault: falseEnvironment variable: ZEROEVAL_DEBUG (set to "true")Environment variables reference
Here’s a complete list of environment variables the SDK recognizes:| Variable | Description | Required |
|---|---|---|
ZEROEVAL_API_KEY | Your ZeroEval API key | Yes |
ZEROEVAL_API_URL | Custom API endpoint URL | No |
ZEROEVAL_WORKSPACE_NAME | Workspace identifier | No |
ZEROEVAL_DEBUG | Enable debug logging ("true") | No |
Checking initialization status
You can check whether the SDK has been initialized:Example: Using .env file
Create a.env file in your project root:
.env
dotenv package):
Debug mode
When troubleshooting, enable debug mode to see detailed logs:In debug mode, API keys are automatically masked in logs (e.g.,
zer_****key) for security.Next steps
Quickstart
Build your first traced application
Manual tracing
Learn how to create custom spans