Skip to main content
GitHub

Configuration

Configure the Risicare SDK for your application.

Configure the Risicare SDK to connect to your project and customize tracing behavior.

Basic Setup

import risicare
 
risicare.init(
    api_key="rsk-...",              # Or use RISICARE_API_KEY env var
    service_name="my-agent",        # Identify your service
    environment="production",       # Environment name
)

API Key = Project

Your API key is scoped to the project it was created under (visible in Settings → General). No separate project_id is needed — the gateway resolves it from your key.

Configuration Options

Required

OptionTypeDescription
api_keystrYour Risicare API key. Starts with rsk-. Each key is scoped to one project.

Optional

OptionTypeDefaultDescription
endpointstr"https://app.risicare.ai"Gateway endpoint URL
environmentstr"development"Environment name (development, staging, production)
service_namestrNoneService name for within-project organization
service_versionstrNoneService version for traces
enabledboolTrueEnable/disable tracing globally
trace_contentboolTrueCapture prompt/completion content
sample_ratefloat1.0Sampling rate (0.0-1.0, clamped)
batch_sizeint100Spans per batch export
batch_timeout_msint1000Milliseconds between batch exports
auto_patchboolTrueAuto-patch ThreadPoolExecutor and asyncio for context propagation
debugboolFalseEnable debug logging
exporterslist[SpanExporter]NoneCustom span exporters (default: HTTP exporter when api_key is provided)
metadatadict{}Global metadata attached to all spans
otlp_endpointstrNoneOTLP/HTTP export endpoint
otlp_headersdictNoneOTLP export headers
otel_bridgeboolFalseEnable OpenTelemetry bridge

Environment Variables

All configuration can be set via environment variables:

export RISICARE_API_KEY="rsk-..."
export RISICARE_ENDPOINT="https://app.risicare.ai"
export RISICARE_ENVIRONMENT="production"
export RISICARE_SERVICE_NAME="my-agent"
export RISICARE_TRACING="true"
export RISICARE_TRACE_CONTENT="true"
export RISICARE_SAMPLE_RATE="1.0"
export RISICARE_SERVICE_NAME="my-service"
export RISICARE_SERVICE_VERSION="1.0.0"
export RISICARE_DEBUG="false"
export RISICARE_OTLP_ENDPOINT="https://otel-collector:4318"
export RISICARE_OTLP_HEADERS="key1=value1,key2=value2"
export RISICARE_OTEL_BRIDGE="false"
VariableMaps To
RISICARE_API_KEYapi_key
RISICARE_ENDPOINTendpoint
RISICARE_ENVIRONMENTenvironment
RISICARE_SERVICE_NAMEservice_name
RISICARE_SERVICE_VERSIONservice_version
RISICARE_TRACINGenabled
RISICARE_TRACE_CONTENTtrace_content
RISICARE_SAMPLE_RATEsample_rate
RISICARE_DEBUGdebug
RISICARE_OTLP_ENDPOINTotlp_endpoint
RISICARE_OTLP_HEADERSotlp_headers
RISICARE_OTEL_BRIDGEotel_bridge

Zero-Code Instrumentation

Set RISICARE_TRACING=true to enable auto-instrumentation without any code changes.

Advanced Configuration

Custom Endpoint

For self-hosted deployments:

risicare.init(
    api_key="rsk-...",
    endpoint="https://your-risicare-instance.com",
)

Sampling

Control trace sampling rate:

risicare.init(
    api_key="rsk-...",
    sample_rate=0.1,  # Sample 10% of traces
)

Programmatic Control

Check Status

if risicare.is_enabled():
    print("Tracing is active")

Flush Pending Spans

# Force export all pending spans
client = risicare.get_client()
client.flush()

Shutdown

# Graceful shutdown - flushes and closes connections
risicare.shutdown(timeout_ms=5000)

Configuration Precedence

Configuration is resolved in this order (highest to lowest priority):

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

Next Steps