Skip to main content

Overview

Solace Agent Mesh uses environment variables to configure brokers, LLM services, and runtime behavior. All environment variables are stored in the .env file in your project root.
The .env file is created automatically during sam init. Never commit this file to version control as it contains sensitive credentials.

Core Environment Variables

Broker Configuration

These variables configure the connection to your Solace PubSub+ broker:
VariableDescriptionDefaultExample
SOLACE_BROKER_URLWebSocket URL for broker connectionws://localhost:8008wss://broker.example.com:443
SOLACE_BROKER_VPNMessage VPN namedefaultproduction-vpn
SOLACE_BROKER_USERNAMEAuthentication usernamedefaultsam-service-account
SOLACE_BROKER_PASSWORDAuthentication passworddefaultsecure-password-123
SOLACE_DEV_MODEEnable internal dev broker (no external broker needed)falsetrue or false
SOLACE_BROKER_URL="wss://production-broker.example.com:443"
SOLACE_BROKER_VPN="production-vpn"
SOLACE_BROKER_USERNAME="service-account"
SOLACE_BROKER_PASSWORD="secure-password"
SOLACE_DEV_MODE="false"

LLM Service Configuration

Configure your LLM provider (OpenAI, Anthropic, Azure, or any LiteLLM-compatible service):
VariableDescriptionRequiredExample
LLM_SERVICE_ENDPOINTLLM API base URLYeshttps://api.openai.com/v1
LLM_SERVICE_API_KEYAPI key for authenticationYessk-proj-...
LLM_SERVICE_PLANNING_MODEL_NAMEModel for complex planning tasksYesopenai/gpt-4o
LLM_SERVICE_GENERAL_MODEL_NAMEModel for general tasksYesopenai/gpt-3.5-turbo
LLM_SERVICE_ENDPOINT="https://api.openai.com/v1"
LLM_SERVICE_API_KEY="sk-proj-..."
LLM_SERVICE_PLANNING_MODEL_NAME="openai/gpt-4o"
LLM_SERVICE_GENERAL_MODEL_NAME="openai/gpt-3.5-turbo"

LLM OAuth 2.0 Configuration

For LLM providers requiring OAuth 2.0 Client Credentials flow:
VariableDescriptionRequiredExample
LLM_SERVICE_OAUTH_ENDPOINTOAuth-protected LLM endpointYes*https://llm.example.com/v1
LLM_SERVICE_OAUTH_TOKEN_URLOAuth token endpointYes*https://auth.example.com/oauth/token
LLM_SERVICE_OAUTH_CLIENT_IDOAuth client IDYes*sam-client-id
LLM_SERVICE_OAUTH_CLIENT_SECRETOAuth client secretYes*client-secret-xyz
LLM_SERVICE_OAUTH_SCOPEOAuth scopes (space-separated)Nollm.read llm.write
LLM_SERVICE_OAUTH_CA_CERT_PATHCustom CA certificate pathNo/path/to/ca-cert.pem
LLM_SERVICE_OAUTH_TOKEN_REFRESH_BUFFER_SECONDSToken refresh buffer timeNo300
LLM_SERVICE_OAUTH_PLANNING_MODEL_NAMEPlanning model (OAuth)Yes*company/planning-model
LLM_SERVICE_OAUTH_GENERAL_MODEL_NAMEGeneral model (OAuth)Yes*company/general-model
*Required only when using OAuth authentication. Use *oauth_planning_model or *oauth_general_model in your YAML configs to enable OAuth.
LLM_SERVICE_OAUTH_ENDPOINT="https://llm.mycompany.com/v1"
LLM_SERVICE_OAUTH_TOKEN_URL="https://auth.mycompany.com/oauth/token"
LLM_SERVICE_OAUTH_CLIENT_ID="sam-production-client"
LLM_SERVICE_OAUTH_CLIENT_SECRET="super-secret-value"
LLM_SERVICE_OAUTH_SCOPE="llm.inference"
LLM_SERVICE_OAUTH_TOKEN_REFRESH_BUFFER_SECONDS="300"
LLM_SERVICE_OAUTH_PLANNING_MODEL_NAME="internal/gpt-4-equivalent"
LLM_SERVICE_OAUTH_GENERAL_MODEL_NAME="internal/gpt-3.5-equivalent"

Project Configuration

VariableDescriptionDefaultExample
NAMESPACETopic namespace prefix for all agentssolace_app/my_project/
LOGGING_CONFIG_PATHPath to logging configurationconfigs/logging_config.yamlconfigs/custom_logging.yaml
NAMESPACE="production/customer_service/"
LOGGING_CONFIG_PATH="configs/logging_config.yaml"
The NAMESPACE must end with a forward slash (/) for proper topic routing.

Web UI Gateway Variables

Configuration for the built-in chat interface:
VariableDescriptionDefaultExample
FASTAPI_HOSTHost address for FastAPI server127.0.0.10.0.0.0
FASTAPI_PORTHTTP port for web UI80008080
FASTAPI_HTTPS_PORTHTTPS port (when SSL enabled)8443443
SESSION_SECRET_KEYSecret key for session encryptionAuto-generatedyour-secret-key-here
ENABLE_EMBED_RESOLUTIONEnable dynamic embeds in responsestruetrue or false
SSL_KEYFILEPath to SSL private key fileEmpty/path/to/privkey.pem
SSL_CERTFILEPath to SSL certificate fileEmpty/path/to/fullchain.pem
SSL_KEYFILE_PASSWORDPassword for encrypted key fileEmptykey-password
FASTAPI_HOST="127.0.0.1"
FASTAPI_PORT="8000"
SESSION_SECRET_KEY="randomly-generated-secret-key"
ENABLE_EMBED_RESOLUTION="true"
SSL_KEYFILE=""
SSL_CERTFILE=""
To generate a secure session secret key:
python3 -c "import secrets; print(secrets.token_urlsafe(32))"

Platform Service Variables

Configuration for the Platform API (management interface):
VariableDescriptionDefaultExample
PLATFORM_API_HOSTPlatform API host127.0.0.10.0.0.0
PLATFORM_API_PORTPlatform API port80019000
PLATFORM_SERVICE_URLFull Platform API URLAuto-generatedhttp://localhost:8001
PLATFORM_API_HOST="0.0.0.0"
PLATFORM_API_PORT="8001"
PLATFORM_SERVICE_URL="http://localhost:8001"

Artifact Storage Variables

Configure where agent-generated files are stored:

S3-Compatible Storage

For AWS S3, MinIO, or other S3-compatible services:
VariableDescriptionDefaultExample
S3_BUCKET_NAMES3 bucket nameEmptysam-artifacts
S3_ENDPOINT_URLS3 endpoint (leave empty for AWS S3)Emptyhttps://s3.us-east-1.amazonaws.com
S3_REGIONAWS regionus-east-1us-west-2
AWS_ACCESS_KEY_IDAWS access keyN/AAKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEYAWS secret keyN/AwJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
S3_BUCKET_NAME="my-sam-artifacts"
S3_ENDPOINT_URL=""
S3_REGION="us-east-1"
AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE"
AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"

Google Cloud Storage

For GCS artifact storage:
GOOGLE_APPLICATION_CREDENTIALS="/path/to/service-account-key.json"
GCS_BUCKET_NAME="sam-artifacts-bucket"

Database Variables

For SQL-based session and state storage:
VariableDescriptionDefaultExample
ORCHESTRATOR_DATABASE_URLOrchestrator session databasesqlite:///data/orchestrator.dbpostgresql://user:pass@host/db
WEB_UI_GATEWAY_DATABASE_URLWeb UI session databasesqlite:///data/webui_gateway.dbpostgresql://user:pass@host/db
ORCHESTRATOR_DATABASE_URL="sqlite:///data/orchestrator.db"
WEB_UI_GATEWAY_DATABASE_URL="sqlite:///data/webui_gateway.db"

Optional Service Variables

Image Generation

For agents that generate images:
IMAGE_SERVICE_ENDPOINT="https://api.openai.com/v1"
IMAGE_SERVICE_API_KEY="sk-..."
IMAGE_MODEL_NAME="dall-e-3"

Report Generation

For custom report generation models:
LLM_REPORT_MODEL_NAME="openai/gpt-4o"

Auto-Summarization

Prevents token limit errors by auto-summarizing conversation history:
SAM_ENABLE_AUTO_SUMMARIZATION="false"  # Set to "true" to enable
SAM_COMPACTION_PERCENTAGE="0.25"  # Compact 25% of history when threshold exceeded

Queue Configuration

USE_TEMPORARY_QUEUES="true"  # Use temporary queues for agent responses

Environment Variable Substitution

YAML configuration files can reference environment variables using ${VAR_NAME} or ${VAR_NAME, default_value} syntax:
# In shared_config.yaml
broker_connection:
  broker_url: ${SOLACE_BROKER_URL, ws://localhost:8008}
  broker_username: ${SOLACE_BROKER_USERNAME, default}
  
model:
  model: ${LLM_SERVICE_PLANNING_MODEL_NAME}
  api_base: ${LLM_SERVICE_ENDPOINT}
  api_key: ${LLM_SERVICE_API_KEY}

Security Best Practices

1

Never Commit .env Files

Add .env to your .gitignore:
.gitignore
.env
.env.*
!.env.example
2

Use Environment-Specific Files

Create separate env files for different environments:
.env.development
.env.staging  
.env.production
3

Restrict File Permissions

Protect your .env file:
chmod 600 .env
4

Rotate Secrets Regularly

  • Rotate API keys periodically
  • Use different credentials per environment
  • Monitor for unauthorized access
5

Use Secret Management Services

For production, consider:
  • AWS Secrets Manager
  • HashiCorp Vault
  • Azure Key Vault
  • Google Secret Manager

Example .env File

Complete example with all common variables:
# Broker Configuration
SOLACE_BROKER_URL="ws://localhost:8008"
SOLACE_BROKER_VPN="default"
SOLACE_BROKER_USERNAME="default"
SOLACE_BROKER_PASSWORD="default"
SOLACE_DEV_MODE="false"

# LLM Configuration
LLM_SERVICE_ENDPOINT="https://api.openai.com/v1"
LLM_SERVICE_API_KEY="sk-proj-..."
LLM_SERVICE_PLANNING_MODEL_NAME="openai/gpt-4o"
LLM_SERVICE_GENERAL_MODEL_NAME="openai/gpt-3.5-turbo"

# Project Settings
NAMESPACE="my_project/"
LOGGING_CONFIG_PATH="configs/logging_config.yaml"

# Web UI Gateway
FASTAPI_HOST="127.0.0.1"
FASTAPI_PORT="8000"
FASTAPI_HTTPS_PORT="8443"
SESSION_SECRET_KEY="your-random-secret-key-here"
ENABLE_EMBED_RESOLUTION="true"
SSL_KEYFILE=""
SSL_CERTFILE=""
SSL_KEYFILE_PASSWORD=""

# Platform Service
PLATFORM_API_HOST="127.0.0.1"
PLATFORM_API_PORT="8001"
PLATFORM_SERVICE_URL="http://127.0.0.1:8001"

# Artifact Storage
S3_BUCKET_NAME=""
S3_ENDPOINT_URL=""
S3_REGION="us-east-1"

# Database URLs
ORCHESTRATOR_DATABASE_URL="sqlite:///data/orchestrator.db"
WEB_UI_GATEWAY_DATABASE_URL="sqlite:///data/webui_gateway.db"

Troubleshooting

Variables Not Loading

If environment variables aren’t being recognized:
  1. Check .env file exists in project root
  2. Verify no syntax errors (no spaces around =)
  3. Restart the agent mesh: sam run
  4. Check for typos in variable names

Invalid Values

If you see “invalid value” errors:
  1. Check for extra quotes or spaces
  2. Boolean values should be true or false (lowercase)
  3. URLs should include protocol (http:// or https://)
  4. Namespaces must end with /

Missing Required Variables

If required variables are missing:
# Re-run initialization to regenerate .env
sam init

# Or manually add missing variables from the example above

Next Steps

Build docs developers (and LLMs) love