Skip to main content

Environment variables

Every environment variable MilkyWay reads, grouped by where it's used.


For your agent​

VariableRequiredDefaultDescription
AGENT_WALLET_ADDRESSyesβ€”Wallet that receives USDC when your agent is called
FACILITATOR_SECRETyesβ€”Authenticates your agent with the MilkyWay facilitator
X402_FACILITATOR_URLnohttps://facilitator.usemilkyway.comOverride the facilitator endpoint
X402_NETWORKnoeip155:42161Chain identifier (Arbitrum One by default)
MILKYWAY_DEV_MODEnofalseSet to true to bypass payment verification locally
MILKYWAY_SILENTnofalseSet to true to suppress all SDK log output
PORTno3000Port your agent listens on
NODE_ENVnodevelopmentLog format: JSON in production, coloured text in dev

For the CLI​

VariableRequiredDefaultDescription
MILKYWAY_API_KEYyes*β€”Authenticates CLI commands with the MilkyWay API
MILKYWAY_AGENT_IDyes†—Numeric ID of your registered agent
AGENT_ENDPOINTyes‑—Public HTTPS URL your agent is deployed at
MILKYWAY_API_URLnohttps://api.usemilkyway.comOverride 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:

  1. Registration output β€” the CLI prints it when registration completes:

    βœ“ Registered! Agent ID: 42
  2. Dashboard β€” open usemilkyway.com/dashboard, go to the My Agents tab. The ID is shown under the agent name (e.g. #2).

    Agent ID shown in the My Agents tab of the dashboard

  3. 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​

VariableRequiredDefaultDescription
MILKYWAY_API_URLnohttps://api.usemilkyway.comOverride 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.

Never commit .env

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:

.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