Skip to main content
GitHub

JS Configuration

Configure the Risicare JavaScript SDK.

Complete configuration reference for the JavaScript/TypeScript SDK.

RisicareConfig Interface

interface RisicareConfig {
  // Required
  apiKey?: string;          // Each key is scoped to one project
 
  // Deprecated
  projectId?: string;       // DEPRECATED — emits console.warn. Will be removed in v1.0.
 
  // Optional
  endpoint?: string;
  environment?: string;     // Within-project organization
  serviceName?: string;     // Within-project organization
  serviceVersion?: string;
  enabled?: boolean;
  traceContent?: boolean;
  compress?: boolean;
  sampleRate?: number;
  batchSize?: number;
  batchTimeoutMs?: number;
  maxQueueSize?: number;
  debug?: boolean;
  metadata?: Record<string, unknown>;
}

Configuration Options

OptionTypeDefaultDescription
apiKeystringenvAPI key (or RISICARE_API_KEY). Each key is scoped to one project.
projectIdstringenvDeprecated — emits console.warn. Project is derived from the API key; will be removed in v1.0.
endpointstring"https://app.risicare.ai"Gateway endpoint URL
environmentstring"development"Environment name (within-project org)
serviceNamestringundefinedService name (within-project org)
serviceVersionstringundefinedService version for traces
enabledbooleantrueEnable tracing (true if apiKey provided)
traceContentbooleantrueCapture prompts/completions
compressbooleanfalseEnable gzip compression for exports
sampleRatenumber1.0Trace sampling rate (0-1)
batchSizenumber100Spans per batch
batchTimeoutMsnumber1000Milliseconds between flushes
maxQueueSizenumber10000Max queued spans
debugbooleanfalseEnable debug logging
metadataobjectGlobal metadata for all traces

Environment Variable Mapping

ConfigEnvironment Variable
apiKeyRISICARE_API_KEY
projectId (deprecated)RISICARE_PROJECT_ID
endpointRISICARE_ENDPOINT
environmentRISICARE_ENVIRONMENT
enabledRISICARE_TRACING
traceContentRISICARE_TRACE_CONTENT
sampleRateRISICARE_SAMPLE_RATE
compressRISICARE_COMPRESS
serviceNameRISICARE_SERVICE_NAME
serviceVersionRISICARE_SERVICE_VERSION
debugRISICARE_DEBUG

Runtime Control

Enable/Disable

import { enable, disable, isEnabled } from 'risicare';
 
// Check status
if (isEnabled()) {
  console.log('Tracing is active');
}
 
// Disable temporarily
disable();
 
// Re-enable
enable();

Flush and Shutdown

import { flush, shutdown } from 'risicare';
 
// Force export pending spans
await flush();
 
// Graceful shutdown
await shutdown();

Configuration Precedence

Configuration is resolved in order (highest priority first):

  1. Explicit init() parameters
  2. Environment variables
  3. Default values

Advanced Configuration

Custom Endpoint

Override the default gateway endpoint (https://app.risicare.ai) — for example, to send spans through an outbound proxy your network requires:

init({
  apiKey: 'rsk-...',
  endpoint: 'https://llm-egress-proxy.internal.example.com',
});

Risicare is a hosted service

Risicare runs as a managed service. There is no self-hosted or on-premise Risicare instance to point this at — endpoint retargets where the SDK sends spans (a proxy or a non-default gateway host), not where Risicare itself runs.

Sampling

Control trace sampling rate:

init({
  apiKey: 'rsk-...',
  sampleRate: 0.1, // Sample 10% of traces
});

Next Steps