Skip to main content

Overview

The initialize() method sets up the tracing client and establishes connection to Keywords AI. This must be called before using any tracing methods.

Signature

Basic Usage

Constructor Options

Complete Example

Environment Variables

You can also configure using environment variables:
.env

Configuration Options

string
required
Your Keywords AI API key from the dashboard
string
default:"https://api.keywordsai.co"
Keywords AI API base URL
string
Application name for identifying traces in the dashboard
object
Modules to automatically instrument:
  • openAI: OpenAI SDK class
  • anthropic: Anthropic SDK class
boolean
default:false
If true, sends spans immediately instead of batching them
string
default:"warn"
Logging verbosity: "debug", "info", "warn", "error"

Best Practices

  • Always call initialize() before using any tracing methods
  • Initialize once at application startup
  • Use environment variables for sensitive configuration
  • Call shutdown() before application exit to flush pending spans
  • Enable auto-instrumentation for supported SDKs