AI tools and agents are increasingly being used for tasks that require credentials like passwords, API tokens, and one-time password codes to complete. When you supply these credentials in plaintext, like by pasting a secret directly into an agentic browser when prompted to sign in, your secrets can leak into the LLM context. Storing API tokens for AI services in plaintext creates another risk. Hardcoded tokens inDocumentation Index
Fetch the complete documentation index at: https://www.1password.dev/llms.txt
Use this file to discover all available pages before exploring further.
.env files, mcp.json files, and config files can be committed to source control or accidentally shared, allowing anyone who finds them to access your accounts.
1Password gives you secure ways to provide secrets to AI tools and agents. Store your credentials in 1Password, then load them into your AI workflows without exposing them in plaintext or allowing agents to directly handle your secrets.
The security principles guiding 1Password's approach to AI
How 1Password applies ideas like secrets staying secret, deterministic authorization, auditability, and least privilege when building and integrating AI.
Secure AI API keys
If you use AI services like OpenAI, Anthropic, or Google in your applications or scripts, you may have plaintext API keys stored in environment variables,.env files, or shell profiles.
1Password Environments (beta) allow you to manage your API keys and other project secrets together in 1Password, then securely load them into your code when you need them.
To get started:
- Create an Environment in 1Password and add the API keys and other secrets your AI workflow needs as variables. If you have an existing
.envfile for your project, you can import it. - Create a locally mounted
.envfile for the Environment. The contents of this file aren’t tracked by Git or stored on disk, and are only available at the moment you access it. - Verify you can access your variables and make sure they work with your tools.
.env files or shell profiles (~/.zshrc, ~/.bashrc).
Add validation for AI-assisted coding
If you use AI coding agents in tools like Cursor, GitHub Copilot, Claude Code, or Windsurf, you can use 1Password hooks to validate that your locally mounted.env files are properly configured before the agent executes shell commands.
If any required .env files are missing or invalid, the hook prevents the agent from executing and the agent provides instructions for how to fix the issue.
Create and manage Environments
Store your AI API keys in an Environment.
Access secrets through local .env files
Sync an Environment to a local
.env file.Install the validation hook
Validate locally mounted
.env files before your agent runs shell commands.Secure MCP server config files
MCP server configurations (likemcp.json) often include API tokens and other credentials as environment variables. Yours might look something like this:
- Install the latest beta of 1Password CLI.
- Create an Environment in 1Password and add the credentials your MCP server configuration needs as variables.
- Open the Environment you just created and select Manage environment > Copy environment ID.
-
Wrap the command to start your MCP server with
op run --environmentto provision your Environment’s variables for the duration of the MCP server process:
You can also load your API tokens from 1Password at runtime using
op run and secret references.Autofill in browser-based agents (early access)
When browser-based AI agents need to sign in to websites, they typically prompt you to enter your login details manually. This exposes your credentials to the agent and the underlying model. 1Password Agentic Autofill (early access) provides a secure alternative. Instead of handing secrets directly to the agent, you tell the agent to sign in using 1Password. When the agent needs to authenticate, 1Password prompts you to approve or deny the request. If you approve, the 1Password browser extension autofills your login details over an end-to-end encrypted channel and the agent completes the sign-in process without ever seeing your credentials. Agentic Autofill is currently available through Browserbase Director, a no-code AI agent for web-based tasks.Set up Agentic Autofill
Get started with Agentic Autofill and Browserbase Director.