Use init() to setup the Gentrace SDK with your API credentials and configuration
init()
function initializes the Gentrace SDK with your API credentials and configuration options. This function must be called early in your application setup to configure the SDK globally before using any other Gentrace functionality.
Starting with the latest SDK versions, init()
also automatically configures OpenTelemetry by default, eliminating the need for manual OpenTelemetry setup in most cases.
init()
function:
otelSetup
configuration:
http://localhost:4318/v1/traces
http://otel-collector:4318/v1/traces
http://otel-collector.observability.svc.cluster.local:4318/v1/traces
init()
, you can use environment variables:
GENTRACE_API_KEY
: Your Gentrace API keyGENTRACE_BASE_URL
: Custom base URL for the API (useful for self-hosted instances)GENTRACE_LOG
(TypeScript only): Log level settinginit()
function will throw an error if required configuration is missing:
init()
automatically configures OpenTelemetry by default. This eliminates the need for manual OpenTelemetry setup in most cases. If you need custom OpenTelemetry configuration or want to disable automatic setup, use the otelSetup
(TypeScript) or otel_setup
(Python) parameter.init()
before your main execution logic to ensure Gentrace is configured before using any tracing functionality:
traced()
- Lower-level function tracinginteraction()
- Instrument AI functions for tracingexperiment()
- Create testing contexts for grouping evaluationsevalDataset()
/ eval_dataset()
- Run tests against datasetseval()
/ evalOnce()
- Run individual test cases