Skip to content

Environment Variables

Mia reads environment variables from two sources:

  1. ~/.mia/.env — Primary location. Created during setup. Takes precedence.
  2. Process environment — Inherited from your shell.
VariableDescription
ANTHROPIC_API_KEYAnthropic API key for Claude Code plugin
GEMINI_API_KEYGoogle API key for Gemini plugin
OPENAI_API_KEYOpenAI API key for Codex plugin

These keys are stored with 0o600 permissions (owner read/write only) and masked in logs (first 10 + last 4 characters shown).

VariableDefaultDescription
MIA_MAX_ITERATIONS15Maximum iterations per dispatch (limits tool use loops)
MIA_DEBUG0Set to 1 to enable debug-level logging

If you’re using Claude Code with a Claude Max or Pro subscription, authentication is handled via browser login:

Terminal window
mia setup
# or directly:
claude setup-token

This stores a long-lived token in ~/.mia/.env as ANTHROPIC_API_KEY.

For Gemini, you can use either:

  • API key: Set GEMINI_API_KEY in ~/.mia/.env
  • OAuth: Browser-based login flow (handles token refresh automatically)
Terminal window
# View current auth status
mia doctor
# Re-authenticate
mia setup
# Remove stored credentials
# Delete the relevant line from ~/.mia/.env
  • API keys in ~/.mia/.env are file-permission protected (0o600)
  • Keys are never logged in full — always masked
  • P2P connections are encrypted end-to-end
  • No credentials are sent to any server except the respective AI provider