Skip to content

Environment Variables ​

Environment variables configure service addresses, model credentials, and other deployment options.

Set Environment Variables ​

Configuration scopeApply behavior
Local console settingsProcess variables and .env override matching saved console values at every startup.
Platform console settingsEnvironment variables initialize settings once; later changes use saved console values. Credentials come from the deployment environment.
Startup settings and deployment credentialsHTTP binding, database, service identity, A2A identity, and additional IM channels always use the deployment environment. Restart affected services after changes.

Local development uses .env in the repository root; installed binaries use .env in the installation directory. The default macOS/Linux path is shown below. For a single startup, set variables before the startup command.

bash
ENV_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/device-agent/current/.env"
touch "$ENV_FILE"

Deployment administrators maintain platform variables; see Platform Deployment and Platform Operations. For daily settings, see Console Settings; for individual prompts, vocabulary, and responses, see Device Agent Configuration.

IoT Provider ​

VariableNotes
IOT_PLATFORM_PROVIDER_IDInitial IoT provider: default, fleets, or thingsneural.
FLEETS_API_URLFleets management API URL.
FLEETS_API_KEY / FLEETS_API_SECRET / FLEETS_BEARER_TOKENFleets credentials injected through the deployment environment.
FLEETS_MQTT_BROKER_URL / FLEETS_MQTT_WEBSOCKET_URLFleets MQTT and browser WebSocket URLs.
THINGSNEURAL_URL / THINGSNEURAL_API_URLThingsNeural service URL; the latter is a compatibility alias.
THINGSNEURAL_ACCESS_KEY / THINGSNEURAL_SECRET_KEYThingsNeural connection credentials.
THINGSNEURAL_PROJECT_ID / THINGSNEURAL_CATEGORY_IDThingsNeural project and category identifiers.
THINGSNEURAL_MQTT_URL / THINGSNEURAL_CLIENT_API_URL / THINGSNEURAL_LOGIN_URLMQTT, client API, and login URLs.

Configure the selected provider's parameters; see IoT Platform Integration.

MQTT ​

VariableNotes
MQTT_BROKER_URLBroker URL for the gateway and devices, such as mqtt://localhost:1883.
VITE_MQTT_WS_URLBrowser MQTT WebSocket URL, such as ws://localhost:8083/mqtt.
MQTT_CLIENT_IDGateway MQTT client ID.
MQTT_PROTOCOL_VERSIONMQTT protocol version. Supports 4 and 5.
MQTT_KEEPALIVE_SECONDS / MQTT_KEEP_ALIVE_SECONDSKeep Alive interval, in seconds.
MQTT_CONNECT_TIMEOUT_MSConnection timeout, in milliseconds.
MQTT_AUTO_RECONNECTWhether to reconnect automatically.
MQTT_RECONNECT_PERIOD_MSReconnect interval, in milliseconds.
MQTT_CLEAN_STARTWhether to use Clean Start.
MQTT_SESSION_EXPIRY_INTERVAL_SECONDSMQTT 5 session expiry interval, in seconds.
MQTT_USERNAME / MQTT_PASSWORDMQTT credentials for the gateway and devices.
VITE_MQTT_USERNAME / VITE_MQTT_PASSWORDMQTT credentials for direct browser connections to the broker.

TLS variables:

VariableNotes
MQTT_TLS_ENABLEDEnable MQTT TLS.
MQTT_TLS_INSECURESet to true to disable server certificate verification.
MQTT_TLS_REJECT_UNAUTHORIZEDWhether to verify the server certificate.
MQTT_TLS_CA_FILECA certificate path.
MQTT_TLS_CERT_FILEClient certificate path.
MQTT_TLS_KEY_FILEClient private key path.
MQTT_TLS_KEY_PASSPHRASEClient private key passphrase.
MQTT_TLS_SERVER_NAMETLS Server Name.

Topic templates apply only to the default provider; Fleets and ThingsNeural use their native topic contracts:

bash
MQTT_TOPIC_PRODUCT_IN=device-agent/{productId}/in
MQTT_TOPIC_PRODUCT_OUT=device-agent/{productId}/out
MQTT_TOPIC_DEVICE_IN=device-agent/{productId}/device/{deviceId}/in
MQTT_TOPIC_DEVICE_OUT=device-agent/{productId}/device/{deviceId}/out
MQTT_TOPIC_DEVICE_COMMAND=device-agent/{productId}/device/{deviceId}/commands
MQTT_TOPIC_DEVICE_RESPONSE=device-agent/{productId}/device/{deviceId}/responses
MQTT_TOPIC_TELEMETRY=v1/{productId}/{deviceId}/telemetry
MQTT_TOPIC_EVENT=v1/{productId}/{deviceId}/event
MQTT_TOPIC_NTP_REQUEST=device-agent/{productId}/device/{deviceId}/ntp/request
MQTT_TOPIC_NTP_RESPONSE=device-agent/{productId}/device/{deviceId}/ntp/response

Topic templates must keep the {productId} and {deviceId} placeholders. See MQTT Access for topics and payloads.

Models and Vision ​

VariableNotes
LLM_PROVIDERPrimary agent model provider.
LLM_MODELPrimary agent model name.
LLM_BASE_URLCustom model URL for OpenAI-compatible endpoints or local model services.
LLM_API_KEYGeneric model API key.
OPENAI_API_KEY / ANTHROPIC_API_KEY / KIMI_API_KEY / QWEN_API_KEYProvider-specific API keys.
DOUBAO_API_KEY / ARK_API_KEYVolcengine Ark credentials for doubao, checked in order: DOUBAO_API_KEY, ARK_API_KEY, LLM_API_KEY. Not interchangeable with VOLCENGINE_SPEECH_*.
CLOUDFLARE_API_KEYAPI key for Cloudflare Workers AI or AI Gateway.
CLOUDFLARE_ACCOUNT_IDCloudflare Account ID, used when the corresponding console field is empty.
CLOUDFLARE_GATEWAY_IDAI Gateway ID for cloudflare-ai-gateway, used when the corresponding console field is empty.
OPENAI_CODEX_AUTH_FILECodex auth file path for the openai-codex provider.
OPENAI_CODEX_ACCESS_TOKENAccess token for the openai-codex provider.
AGENT_MAX_ITERATIONSMaximum iterations for one agent task.
LLM_REASONING_ENABLEDWhether model reasoning (thinking) is enabled. Defaults to false.
LLM_REASONING_EFFORTReasoning effort: minimal, low, medium (default), high, xhigh, or max. Requires reasoning to be enabled and model support; the console shows the supported range.
VISION_ENABLEDWhether vision is enabled.
VISION_PROVIDERauto reuses an agent model that supports images; dashscope uses a separate vision model.
VISION_MODELDashScope vision model name.
VISION_API_KEYDashScope vision model API key.
VISION_TIMEOUT_MSVision analysis timeout, in milliseconds.
TYPESAFE_API_KEYAPI key for the Jev decision model. Initializes the local value; injected only into the platform Worker.

See LLM Configuration for model and reasoning options, and Vision Configuration for vision options. Change legacy LLM_PROVIDER=kimi to moonshotai-cn; keep the model ID and API key unchanged.

auto reuses the agent model's API configuration; dashscope requires separate VISION_MODEL and VISION_API_KEY values.

HTTP, Frontend, and Data Storage ​

HTTP and Frontend ​

VariableNotes
AGENT_GATEWAY_HTTP_HOSTConsole and API bind address: 127.0.0.1 locally, 0.0.0.0 for server or LAN access. Platform values follow deployment configuration.
AGENT_GATEWAY_HTTP_PORTConsole and HTTP API port. Defaults to 3000.
AGENT_GATEWAY_HTTP_TLS_ENABLEDtrue enables direct HTTPS; false uses HTTP. If omitted, providing both certificate and key enables HTTPS.
AGENT_GATEWAY_HTTP_TLS_CERT_FILE / AGENT_GATEWAY_HTTP_TLS_KEY_FILEHTTPS certificate and private key paths; configure both. Relative paths use the workspace or installation root.
AGENT_GATEWAY_HTTP_TLS_PASSPHRASEHTTPS private key passphrase.
VITE_API_BASE_URLFrontend API base URL; usually unnecessary with a same-origin proxy.
VITE_DEVICE_AGENT_PENDING_TIMEOUT_MSTimeout for console Device Agent creation or responses, in milliseconds.

VITE_ variables are read by the frontend dev server or build. Restart the frontend or rebuild after changes.

Data Storage and Service Roles ​

VariableNotes
DATABASE_DRIVERLocal runtimes use sqlite (default); platform deployments use postgres.
DATABASE_URLPlatform PostgreSQL connection string. Verify certificates in production; use sslmode=disable only for local development.
DEVICE_AGENT_ROLEPlatform role: cloud-api, cloud-worker, or cloud-ingress. cloud-all runs all roles in one process for development only.

Authentication and Licensing ​

VariableNotes
AGENT_GATEWAY_API_TOKENOptional Bearer token for service calls, at least 32 characters.
AGENT_GATEWAY_CONSOLE_AUTH_ENABLEDSet to true locally to enable provider SSO; requires provider console-login support. The platform enables SSO checks automatically for these providers.
AGENT_GATEWAY_CONSOLE_SESSION_SECRETProvider console-session signing secret: at least 32 random characters, identical across API replicas.
WEBHOOK_CREDENTIAL_MASTER_KEYRequired Webhook credential encryption key for PostgreSQL: a Base64-encoded 32-byte key.
DEVICE_AGENT_LICENSE_ADMIN_TOKENSeparate credential for signed License imports: at least 32 characters, distinct from the service token and session secret. Imports are unavailable without it.
DEVICE_AGENT_PUBLIC_BASE_URLPublic console URL. Set when a reverse proxy terminates HTTPS, to validate browser License import origins.
DEVICE_AGENT_LICENSE_FILEOptional signed license file for first activation; renew later from License settings.

Service tokens authenticate service calls; they do not provide end-user identity or role permissions. HTTPS encrypts transport. Shared access requires a trusted network or authenticated entry point.

See Platform Deployment for service configuration and License for request licensing. AI Credits manages device consumption policies separately.

Enable Direct HTTPS ​

Example for a local service; restart Device Agent after configuration:

bash
AGENT_GATEWAY_HTTP_HOST=0.0.0.0
AGENT_GATEWAY_HTTP_PORT=3000
AGENT_GATEWAY_HTTP_TLS_ENABLED=true
AGENT_GATEWAY_HTTP_TLS_CERT_FILE=/etc/device-agent/fullchain.pem
AGENT_GATEWAY_HTTP_TLS_KEY_FILE=/etc/device-agent/privkey.pem

After restarting, access the console and HTTP API at https://<host>:3000. See Installation for browser and certificate verification.

Platform Monitoring ​

The deployment administrator enables metric collection using the delivered runbook and configures Prometheus on the platform API service:

VariableNotes
DEVICE_AGENT_PROMETHEUS_URLPrometheus HTTP/HTTPS base URL, without credentials, query, or fragment. Monitoring is unavailable if unset.
DEVICE_AGENT_PROMETHEUS_NAMESPACEOptional namespace filter: a lowercase DNS label matching the metrics' device_agent_namespace label.

Voice ​

VariableNotes
VOICE_ENABLEDWhether the voice channel is enabled.
VOICE_HOSTVoice bind address: 127.0.0.1 locally, 0.0.0.0 for LAN or server access. The platform publishes a public URL through its deployment entry point.
VOICE_PORTVoice service bind port. Defaults to 3001.
VITE_ASR_SAMPLE_RATEASR sample rate used by browser audio capture.
VOICE_REGIONVoice region. Supports cn, us, eu, and global.
VOICE_TLS_ENABLEDWhether voice service TLS is enabled.
VOICE_TLS_CERT_FILE / VOICE_TLS_KEY_FILEVoice service TLS certificate and private key paths.
VOICE_TLS_PASSPHRASEVoice service TLS private key passphrase.

Speech provider variables:

ProviderVariables
VolcengineVOLCENGINE_SPEECH_APP_ID, VOLCENGINE_SPEECH_ACCESS_KEY, VOLCENGINE_ASR_RESOURCE_ID, VOLCENGINE_ASR_LANGUAGE, VOLCENGINE_TTS_RESOURCE_ID, VOLCENGINE_TTS_VOICE, VOLCENGINE_TTS_VOICES, VOLCENGINE_TTS_EXPLICIT_LANGUAGE, VOLCENGINE_TTS_SAMPLE_RATE
Aliyun DashScopeALIYUN_DASHSCOPE_API_KEY, ALIYUN_ASR_MODEL, ALIYUN_ASR_LANGUAGE, ALIYUN_ASR_VOCABULARY_ENABLED, ALIYUN_TTS_MODEL, ALIYUN_TTS_VOICE, ALIYUN_TTS_VOICES, ALIYUN_TTS_SAMPLE_RATE
AWSAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_TRANSCRIBE_LANGUAGE_CODE, AWS_POLLY_VOICE, AWS_POLLY_SAMPLE_RATE
ElevenLabsELEVENLABS_API_KEY, ELEVENLABS_API_ENDPOINT, ELEVENLABS_ASR_MODEL_ID, ELEVENLABS_ASR_LANGUAGE, ELEVENLABS_TTS_MODEL_ID, ELEVENLABS_TTS_VOICE, ELEVENLABS_TTS_VOICES, ELEVENLABS_TTS_SAMPLE_RATE

See Voice Configuration for settings and Voice Interaction for usage.

IM ​

Settings → Channels supports these channels. Local installations allow credential edits; the platform allows non-secret edits and receives credentials from the deployment environment.

ChannelVariables
FeishuFEISHU_ENABLED, FEISHU_APP_ID, FEISHU_APP_SECRET, FEISHU_ENCRYPT_KEY, FEISHU_VERIFICATION_TOKEN, FEISHU_ALLOW_FROM
DingTalkDINGTALK_ENABLED, DINGTALK_CLIENT_ID, DINGTALK_CLIENT_SECRET, DINGTALK_ALLOW_FROM
DiscordDISCORD_ENABLED, DISCORD_BOT_TOKEN, DISCORD_ALLOW_FROM
TelegramTELEGRAM_ENABLED, TELEGRAM_BOT_TOKEN, TELEGRAM_ALLOW_FROM
SlackSLACK_ENABLED, SLACK_BOT_TOKEN, SLACK_APP_TOKEN, SLACK_SIGNING_SECRET, SLACK_ALLOW_FROM, SLACK_CHANNEL_DIRECT_ENABLED

These channels are configured only through environment variables:

ChannelVariables
WhatsAppWHATSAPP_ENABLED, WHATSAPP_BRIDGE_URL, WHATSAPP_BRIDGE_TOKEN, WHATSAPP_ALLOW_FROM
QQQQ_ENABLED, QQ_APP_ID, QQ_APP_SECRET, QQ_TOKEN, QQ_SANDBOX, QQ_ALLOW_FROM
MatrixMATRIX_ENABLED, MATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, MATRIX_AUTOJOIN, MATRIX_ALLOW_FROM
MoChatMOCHAT_ENABLED, MOCHAT_SERVER_URL, MOCHAT_TOKEN, MOCHAT_BOT_NAME, MOCHAT_ALLOW_FROM
EmailEMAIL_ENABLED, EMAIL_IMAP_HOST, EMAIL_IMAP_PORT, EMAIL_IMAP_USER, EMAIL_IMAP_PASSWORD, EMAIL_IMAP_TLS, EMAIL_SMTP_HOST, EMAIL_SMTP_PORT, EMAIL_SMTP_USER, EMAIL_SMTP_PASSWORD, EMAIL_SMTP_TLS, EMAIL_FROM_ADDRESS, EMAIL_POLL_INTERVAL_MS, EMAIL_ALLOW_FROM

See IM Access for platform-specific setup.

Logging ​

File output and rotation apply to local installations. See Logs and Platform Operations for platform logs and retention.

VariableNotes
LOG_LEVELLog level. Supports debug, info, warn, and error.
LOG_CONSOLE_ENABLEDWhether to write logs to the console.
LOG_FILE_ENABLEDWhether to write logs to files.
LOG_DIRLog directory. Relative paths resolve under the runtime home.
LOG_MAX_SIZE_MBMaximum size of one log file.
LOG_RETENTION_DAYSLog retention days.
LOG_MAX_TOTAL_SIZE_MBMaximum total log file size.
LOG_TIMEZONEFile log timestamp timezone: system or utc.

Tool Permissions ​

VariableNotes
ENABLE_TOOL_EDITOR_MUTATIONSTool editor save and delete permission.
ENABLE_FILE_WRITE_TOOLwrite_file tool permission.
ENABLE_EXECUTE_COMMAND_TOOLexecute_command tool permission.
ALLOWED_EXEC_COMMAND_PREFIXESAllowed command prefixes. An empty value clears the allowlist.
DANGEROUSLY_BYPASS_TOOL_PERMISSIONSServer-only startup flag, excluded from config.json and the console. Set to true to bypass tool permission checks.

Bypass mode skips file-write approvals, command approvals and allowlists, shell safety checks, and tool editor mutation gates. Writes can modify executable code or tool extensions, and commands run with the Gateway's host permissions. Enable only when the Agent, workspace, and all Gateway credentials are trusted.

Tool permissions follow the apply rules above; they do not provide console user or role management.

A2A ​

VariableNotes
A2A_ORG_ID / A2A_UNIT_IDOrganization and unit identity used for A2A registration and discovery. Both default to default.

See A2A for A2A usage.