Guide · local handoff

Give your coding agent an API key without pasting it into chat

Your agent hits a command that needs a token, then tells you not to paste it. Keyrelay gives you somewhere else to type it: a one-time form on your own computer that hands the key to that one command.

Why not paste it, or put it in the command?

With Keyrelay the agent runs the command, you type the key into a browser form, and the command receives it as an environment variable or on standard input. The agent gets the command's output and exit status, with any echo of the key replaced by [REDACTED].

Who this suits

A good fit

  • You use a coding agent such as Claude Code or Codex on your own computer.
  • A CLI command or script needs a token, key, or password you don't want the agent to see.
  • You're at the same computer, with a browser.

Something else fits better

  • You type into the shell that runs the command yourself: read -s is enough.
  • The secret is already in a vault: a password manager CLI such as op run injects it by name.
  • The sign-in needs 2FA, a CAPTCHA, a passkey, or SSO: Keyrelay can't fill those.

What you need

Try it with a made-up value

npx keyrelay run --env DEMO_TOKEN -- printenv DEMO_TOKEN

Open the printed link, type demo-value, and select Send once. printenv prints the value and you see [REDACTED] instead. Afterwards $DEMO_TOKEN isn't set in your shell: only that one command got it.

Set up your agent once

Add this to your agent instructions, such as AGENTS.md or CLAUDE.md:

When a command needs a credential, run it with
`npx keyrelay run --env VARIABLE -- COMMAND` (or `--stdin` if the tool
reads it from standard input) and show me the printed link. Leave the
runner waiting while I enter the credential. For several credentials,
repeat `--field NAME=Label`; the command receives them as one JSON
object. Never ask me to paste credentials into the conversation.

What happens during a handoff

  1. The agent runs the command through keyrelay run. Keyrelay starts a temporary broker on 127.0.0.1 on a random port and prints a one-time link.
  2. You open the link on the same computer. The form shows the exact command and the variable it will receive, then a password field.
  3. You check the command and select Send once. The field clears and the link stops accepting submissions.
  4. Keyrelay shuts the temporary broker down, then runs the command with the key as $VARIABLE, or on standard input with --stdin.
  5. The agent reads the output and exit status. Plain-text echoes of the key are redacted.

The link works only on the computer running the command, because the broker answers only on loopback and only to its exact 127.0.0.1:port address. It also rejects form posts from other origins, so another web page can't submit to it. If nobody sends a key, the request expires after five minutes. Press Ctrl+C to cancel sooner.

Variations

Tools that read the secret from input

Use --stdin instead of --env. Keyrelay writes the secret and a newline to the command's standard input, which suits commands like gh auth login --with-token. It also keeps the key out of the environment, where other programs running as you could read it.

Several values at once

Repeat --field NAME=Label for up to 16 fields. The form shows one password field per label, and the command receives one JSON object keyed by field name.

npx keyrelay run --env X_CREDENTIALS_JSON \
  --field 'apiKey=API Key' --field 'apiSecret=API Key Secret' \
  -- your-command

What it doesn't do

Keyrelay keeps the key out of the conversation. It is not a sandbox. The command you approve gets the real key and can store it, send it, or print it in a form redaction misses, such as base64. A CLI that logs in may save its own token to disk. Read the command on the form before you send, and prefer scoped, short-lived keys. How Keyrelay works covers each limit.

Describes Keyrelay 0.1.6. Full options are in the usage reference.