API Reference
Environment Variables

Environment Variables

Reference for all environment variables used by Mantis SDK.

Insight Configuration

Required for exporting traces to Mantis Insight.

INSIGHT_HOST

The Insight server URL.

PropertyValue
RequiredYes (for Insight export)
Examplehttps://insight.withmetis.ai
export INSIGHT_HOST=https://insight.withmetis.ai

INSIGHT_PUBLIC_KEY

The public key for authentication.

PropertyValue
RequiredYes (for Insight export)
Formatpk-lf-...
export INSIGHT_PUBLIC_KEY=pk-lf-your-public-key

INSIGHT_SECRET_KEY

The secret key for authentication.

PropertyValue
RequiredYes (for Insight export)
Formatsk-lf-...
export INSIGHT_SECRET_KEY=sk-lf-your-secret-key

INSIGHT_OTLP_ENDPOINT

Override the OTLP endpoint (optional).

PropertyValue
RequiredNo
DefaultDerived from INSIGHT_HOST
export INSIGHT_OTLP_ENDPOINT=https://custom.endpoint/v1/traces

Trace Metadata via init()

In addition to environment variables, you can set trace-level metadata programmatically via tracing.init(). This is useful for:

  • Filtering traces by environment (production, staging, development)
  • Tracking app versions for regression debugging
import mantisdk.tracing as tracing
 
tracing.init(
    service_name="my-agent",
    environment="production",  # Filter traces by environment in Insight
    version="1.2.3",           # Track app version for regression debugging
)

These values are set as OpenTelemetry resource attributes and apply to all traces from this process:

  • insight.environment - Maps to the Environment filter in Insight
  • insight.version - Maps to the Version column in Insight

Insight Credentials via init()

You can also pass Insight credentials directly to init() instead of using environment variables:

import mantisdk.tracing as tracing
 
tracing.init(
    service_name="my-agent",
    environment="production",
    version="1.2.3",
    # Pass credentials directly instead of env vars
    insight_host="https://insight.withmetis.ai",
    insight_public_key="pk-lf-...",
    insight_secret_key="sk-lf-...",
)

This is useful when:

  • You want to configure credentials programmatically
  • You're running in an environment where setting env vars is inconvenient
  • You need to switch between different Insight projects dynamically

Priority: Parameters passed to init() take precedence over environment variables

Langfuse-compatible aliasing (optional)

The SDK ingestion helper can mirror credentials into both env namespaces:

  • INSIGHT_HOST, INSIGHT_PUBLIC_KEY, INSIGHT_SECRET_KEY
  • LANGFUSE_HOST, LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY

Use this when downstream tooling expects LANGFUSE_* variables but you still want to target Insight credentials consistently.


LLM API Keys

Required for the LLM providers you use.

OpenAI

export OPENAI_API_KEY=sk-your-openai-key

Anthropic

export ANTHROPIC_API_KEY=sk-ant-your-anthropic-key

Google (Gemini)

export GOOGLE_API_KEY=your-google-api-key

Groq

export GROQ_API_KEY=your-groq-key

Mistral

export MISTRAL_API_KEY=your-mistral-key

Complete .env Example

# Insight configuration
INSIGHT_HOST=https://insight.withmetis.ai
INSIGHT_PUBLIC_KEY=pk-lf-your-public-key
INSIGHT_SECRET_KEY=sk-lf-your-secret-key
 
# LLM API keys (set the ones you need)
OPENAI_API_KEY=sk-your-openai-key
ANTHROPIC_API_KEY=sk-ant-your-anthropic-key
GOOGLE_API_KEY=your-google-api-key

Loading Environment Variables

Using python-dotenv

from dotenv import load_dotenv
load_dotenv()  # Loads from .env file
 
import mantisdk.tracing as tracing
tracing.init()  # Auto-detects credentials

Direct Shell Export

export INSIGHT_HOST=https://insight.withmetis.ai
export INSIGHT_PUBLIC_KEY=pk-lf-...
export INSIGHT_SECRET_KEY=sk-lf-...
python my_agent.py

In Code

import os
os.environ["INSIGHT_HOST"] = "https://insight.withmetis.ai"
os.environ["INSIGHT_PUBLIC_KEY"] = "pk-lf-..."
os.environ["INSIGHT_SECRET_KEY"] = "sk-lf-..."
 
import mantisdk.tracing as tracing
tracing.init()

Checking Configuration

from mantisdk.tracing.exporters.insight import is_insight_configured
import os
 
# Check if all required vars are set
print(f"Insight configured: {is_insight_configured()}")
 
# Debug individual variables
print(f"INSIGHT_HOST: {os.environ.get('INSIGHT_HOST', 'NOT SET')}")
print(f"INSIGHT_PUBLIC_KEY: {os.environ.get('INSIGHT_PUBLIC_KEY', 'NOT SET')[:15]}...")
print(f"INSIGHT_SECRET_KEY: {'SET' if os.environ.get('INSIGHT_SECRET_KEY') else 'NOT SET'}")

Security Best Practices

  1. Never commit .env files - Add .env to .gitignore
  2. Use secrets management - In production, use proper secrets management
  3. Rotate keys regularly - Follow your organization's key rotation policy
  4. Limit permissions - Use keys with minimal required permissions
# .gitignore
.env
.env.local
*.env