remoteagent.online  the open-source control plane for secure, cost-controlled AI agents

API key vault vs .env file for AI agents

Vault or .env? How each stores keys, what leaks look like, and why revocation — not encryption — is the deciding difference for agents.

Updated 2026-08-22Reading time 5 min

The two designs

Property.env fileKey vault
Where the key livesOn every machine, in plain textEncrypted, on the platform
What the agent holdsThe key itselfA revocable device token
Sharing with a teamCopy the file aroundGrant access per member
Revoking one personRotate the key for everyoneOne click, nobody else notices
Leak blast radiusThe key, everywhere it was copiedA token you can kill in seconds

Where a .env is honestly fine

One machine, one person, nothing committed, no agent with shell access — a .env works and costs nothing. The problems start with the second machine, the first teammate, or the first time the agent runs tools that could read or print files.

Where the vault wins

The agent never sees the key, so there is nothing for a prompt-injection attack or a buggy tool to exfiltrate — the argument laid out in API key security. And because access is per member, team key sharing stops being a game of forwarding secrets.

The deciding question

Ask one question: when this key leaks, do I rotate once, or do I hunt down every copy? If the answer is “hunt”, move to the vault — see how the free key agent works and how revocation works in practice.