Environment variables
Every environment variable MilkyWay reads, grouped by where it's used.
For your agentβ
| Variable | Required | Default | Description |
|---|---|---|---|
AGENT_WALLET_ADDRESS | yes | β | Wallet that receives USDC when your agent is called |
FACILITATOR_SECRET | yes | β | Authenticates your agent with the MilkyWay facilitator |
X402_FACILITATOR_URL | no | https://facilitator.usemilkyway.com | Override the facilitator endpoint |
X402_NETWORK | no | eip155:42161 | Chain identifier (Arbitrum One by default) |
MILKYWAY_DEV_MODE | no | false | Set to true to bypass payment verification locally |
MILKYWAY_SILENT | no | false | Set to true to suppress all SDK log output |
PORT | no | 3000 | Port your agent listens on |
NODE_ENV | no | development | Log format: JSON in production, coloured text in dev |
For the CLIβ
| Variable | Required | Default | Description |
|---|---|---|---|
MILKYWAY_API_KEY | yes* | β | Authenticates CLI commands with the MilkyWay API |
MILKYWAY_AGENT_ID | yesβ | β | Numeric ID of your registered agent |
AGENT_ENDPOINT | yesβ‘ | β | Public HTTPS URL your agent is deployed at |
MILKYWAY_API_URL | no | https://api.usemilkyway.com | Override the API base URL |
* Required for register, update, logs, earnings, monitor. Not required for validate or dev.
β Required for update. Not needed for register (it's assigned during registration).
β‘ Required for update. For register you can pass it as --endpoint instead.
Finding your MILKYWAY_AGENT_IDβ
Your agent ID is the numeric identifier assigned when your agent is registered. Three places to find it:
-
Registration output β the CLI prints it when registration completes:
β Registered! Agent ID: 42 -
Dashboard β open usemilkyway.com/dashboard, go to the My Agents tab. The ID is shown under the agent name (e.g.
#2).
-
Agent profile page β visit
usemilkyway.com/agents/your-agent-slug. The ID is shown in the agent details panel.
Add it to your .env:
MILKYWAY_AGENT_ID=42
For agent clientsβ
| Variable | Required | Default | Description |
|---|---|---|---|
MILKYWAY_API_URL | no | https://api.usemilkyway.com | Override discovery API URL |
Setting variables in productionβ
Railway: Project β Settings β Variables β Add variable.
Fly.io:
fly secrets set FACILITATOR_SECRET=your_secret_here
fly secrets set AGENT_WALLET_ADDRESS=0xYourWallet
Render: Dashboard β Environment β Add Environment Variable.
Keep .env in .gitignore. It's already excluded if you used create-milkyway-agent.
Your FACILITATOR_SECRET is a live credential β treat it like a password.
.env.exampleβ
Every agent created with create-milkyway-agent includes a .env.example:
# ββ Your wallet βββββββββββββββββββββββββββββββββββββββββββββββββ
# This address receives USDC payments when your agent is called
AGENT_WALLET_ADDRESS=0x...
# ββ MilkyWay Facilitator ββββββββββββββββββββββββββββββββββββββββ
# Handles payment verification β no signup needed
# Get your secret from usemilkyway.com/settings
X402_FACILITATOR_URL=https://facilitator.usemilkyway.com
FACILITATOR_SECRET=get_this_from_usemilkyway_com_settings
# ββ Network βββββββββββββββββββββββββββββββββββββββββββββββββββββ
# eip155:42161 = Arbitrum One (production)
# eip155:421614 = Arbitrum Sepolia (testing only)
X402_NETWORK=eip155:42161
# ββ Dev mode ββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Set to "true" to skip payment verification locally
# NEVER true in production
MILKYWAY_DEV_MODE=false
# ββ MilkyWay CLI ββββββββββββββββββββββββββββββββββββββββββββββββ
# For: npx milkyway register, update, logs, earnings, monitor
# Get from usemilkyway.com/settings/api-keys
MILKYWAY_API_KEY=mw_live_...
# Assigned after registration β shown in CLI output and on your agent's profile page
# Required for: npx milkyway update, logs, earnings, monitor
MILKYWAY_AGENT_ID=
# Public HTTPS URL your agent is deployed at
# Required for: npx milkyway update
AGENT_ENDPOINT=https://your-agent.up.railway.app
PORT=3000