1Password
@alchemy.run/1password adds 1Password to your stack’s
secret providers through the official
@1password/sdk, in two forms you can combine:
OnePassword.Environmentloads every variable of a 1Password Environment.OnePassword.SecretReferencesloads chosen vault fields fromop://references.
The provider does not modify
process.env or write downloaded values to disk.
pnpm add https://pkg.alchemy.run/@alchemy.run/1password/pr:3743:41147c9Select an Environment
Section titled “Select an Environment”Copy the Environment ID from the 1Password desktop app under Developer > View Environments > View environment > Manage environment > Copy environment ID.
import * as Alchemy from "alchemy";import * as OnePassword from "@alchemy.run/1password";import * as Config from "effect/Config";import * as Effect from "effect/Effect";import * as Layer from "effect/Layer";
export default Alchemy.Stack( "MyApp", { providers: Layer.empty, state: Alchemy.localState(), secrets: [ OnePassword.Environment(({ stage }) => ({ environmentId: stage === "prod" ? "production-id" : "development-id", })), ], }, Effect.gen(function* () { const databaseUrl = yield* Config.Redacted("DATABASE_URL"); // Use databaseUrl to configure your resources. return {}; }),);Plain { environmentId, account? } options work too. Empty values are preserved;
variables marked unmasked in 1Password are also included. Use Config.Redacted
for sensitive values. Later providers override earlier ones, and the stack’s
implicit Secrets.ProcessEnv() retains its usual precedence.
Resolve vault references
Section titled “Resolve vault references”OnePassword.SecretReferences maps config keys to fields in vault items. Both
authentication methods and stage-dependent callbacks work here too.
OnePassword.SecretReferences(({ stage }) => ({ references: { DATABASE_URL: `op://${stage === "prod" ? "Production" : "Development"}/Database/url`, API_KEY: "op://Shared/API/credentials/key", },}));Read these with Config.Redacted("DATABASE_URL") or Config.Redacted("API_KEY").
Use both
Section titled “Use both”Put an Environment and SecretReferences side by side. Later entries win
over earlier ones for the same key:
secrets: [ OnePassword.Environment({ environmentId: "production-id" }), OnePassword.SecretReferences({ references: { STRIPE_KEY: "op://Billing/Stripe/credential" }, }),],Reference syntax
Section titled “Reference syntax”References use op://vault/item/[section/]field, optionally with
?attribute=otp (or totp) or ?ssh-format=openssh. Use 1Password IDs for
names with unusual characters. Alchemy does not check references itself:
1Password parses and resolves them when the stack loads. See
1Password’s reference syntax
and SDK reference support.
Duplicate references are deduplicated and passed to one SDK resolveAll call
per initialization. This does not guarantee a single underlying API request
or quota unit. A missing, malformed or unreadable reference rejects the entire load
with OnePasswordReferenceError; partial config is never installed. Errors
identify the config key without retaining the reference URI or raw SDK error.
Values containing op:// inside an Environment are returned literally, not
recursively resolved. OTP values are snapshots at initialization and are not
refreshed on subsequent config reads.
Authorize with the desktop app
Section titled “Authorize with the desktop app”Unlock 1Password and enable Settings > Developer > Integrate with the 1Password SDKs > Integrate with other apps. Select your account through an Alchemy profile:
alchemy profile edit --add 1PasswordOr configure the selector non-interactively:
alchemy profile edit --add 1Password --method desktop --set account="Family"The profile stores only the account selector. 1Password displays its own authorization prompt when the stack loads secrets; Alchemy does not store a desktop session token. Removing the profile entry removes the selector, not the desktop app’s authorization; lock 1Password to end its active session.
Alternatively, pass account: "Family" to OnePassword.Environment or OnePassword.SecretReferences. The account
is one of:
- the account name in the app’s account switcher, at the top of the sidebar
(
Family, or your team’s name), not your own name; it is case-sensitive - the sign-in address without
https://(my.1password.com) - the account UUID
Explicit account wins over the profile. OP_SERVICE_ACCOUNT_TOKEN, when
set, wins over all desktop selectors. A rejected token never falls back to
desktop authentication.
Store a service account token
Section titled “Store a service account token”A profile can hold a service account token instead of a desktop selector. Use this on a machine without the desktop app, or for a shared testing profile:
alchemy profile edit --add 1Password --method service-account --set token=---set token=- reads the token from stdin, so it never lands in your shell
history. The token is stored with the profile’s other credentials.
Profiles are never consulted in CI; the environment decides. Set a service
account token in OP_SERVICE_ACCOUNT_TOKEN and grant that service account
read access to the selected Environment or referenced vaults:
- run: bun alchemy deploy --stage prod --yes env: OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}OP_SERVICE_ACCOUNT_TOKEN wins over an explicit account and the profile. Desktop authorization is not used when CI=true.
alchemy provider check-env lists the authentication variables.
Authentication variables are read from the process environment, independently of the stack’s secret-provider ordering. A preceding dotenv or remote secrets provider cannot supply or override the 1Password credentials.
Handle rate limits
Section titled “Handle rate limits”1Password service accounts have both hourly limits and account-wide daily
limits. Alchemy maps the SDK’s RateLimitExceededError during authentication
or Environment/reference reads to OnePasswordRateLimitError. It fails immediately
without an automatic retry or an authentication fallback. The SDK does not
expose a structured retry-after duration, so Alchemy does not guess when a
quota will reset.
Check the token’s usage with the optional 1Password CLI:
op service-account ratelimitWait for the relevant quota window to reset and reduce concurrent CI jobs or repeated deployments. Daily limits are shared across service accounts in an account. See 1Password’s rate-limit guide.
One Environment read populates the in-memory config for each secrets-layer initialization. Reading additional config keys does not make additional SDK calls. A new stack evaluation fetches fresh values; there is no persistent cache that could hide rotations or share secrets between stages.
Troubleshoot
Section titled “Troubleshoot”Each failure is its own error, so you can catch the one you care about:
| Error | When |
|---|---|
OnePasswordReferenceError |
A reference is malformed, missing or unreadable; names the config key and 1Password’s error kind |
OnePasswordAccountNotFoundError |
The desktop app has no account matching account |
OnePasswordAuthExpiredError |
The service account token was rejected or expired |
OnePasswordDesktopSessionExpiredError |
The desktop authorization ended; unlock and authorize again |
OnePasswordRateLimitError |
A service-account quota was exceeded |
OnePasswordTimeoutError |
A call didn’t finish in time |
OnePasswordSdkError |
Anything else the SDK reports, or the SDK couldn’t be loaded |
None of them print raw SDK errors, references or values.
Environment and reference reads each time out after 30 seconds. Desktop authentication allows 60 seconds for approval; service-account authentication allows 30 seconds. The SDK exposes no cancellation API, so a timeout stops waiting but cannot cancel an SDK request already in progress. Auth-provider discovery does not load the SDK, contact 1Password, or prompt.
The SDK is a deployment-time dependency. It is not intended to run in a Cloudflare Worker or in your deployed application’s config-loading path.