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.
| Property | Value |
|---|---|
| Required | Yes (for Insight export) |
| Example | https://insight.withmetis.ai |
export INSIGHT_HOST=https://insight.withmetis.aiINSIGHT_PUBLIC_KEY
The public key for authentication.
| Property | Value |
|---|---|
| Required | Yes (for Insight export) |
| Format | pk-lf-... |
export INSIGHT_PUBLIC_KEY=pk-lf-your-public-keyINSIGHT_SECRET_KEY
The secret key for authentication.
| Property | Value |
|---|---|
| Required | Yes (for Insight export) |
| Format | sk-lf-... |
export INSIGHT_SECRET_KEY=sk-lf-your-secret-keyINSIGHT_OTLP_ENDPOINT
Override the OTLP endpoint (optional).
| Property | Value |
|---|---|
| Required | No |
| Default | Derived from INSIGHT_HOST |
export INSIGHT_OTLP_ENDPOINT=https://custom.endpoint/v1/tracesTrace 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 Insightinsight.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_KEYLANGFUSE_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-keyAnthropic
export ANTHROPIC_API_KEY=sk-ant-your-anthropic-keyGoogle (Gemini)
export GOOGLE_API_KEY=your-google-api-keyGroq
export GROQ_API_KEY=your-groq-keyMistral
export MISTRAL_API_KEY=your-mistral-keyComplete .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-keyLoading 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 credentialsDirect Shell Export
export INSIGHT_HOST=https://insight.withmetis.ai
export INSIGHT_PUBLIC_KEY=pk-lf-...
export INSIGHT_SECRET_KEY=sk-lf-...
python my_agent.pyIn 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
- Never commit
.envfiles - Add.envto.gitignore - Use secrets management - In production, use proper secrets management
- Rotate keys regularly - Follow your organization's key rotation policy
- Limit permissions - Use keys with minimal required permissions
# .gitignore
.env
.env.local
*.env