AI and model APIs

Replicate API tokens: find, store, rotate, and use them safely with AI agents

Replicate API tokens are created at replicate.com/account/api-tokens. They are 40-character strings beginning with r8_, sent as a bearer token in the Authorization header, and Replicate's examples read them from REPLICATE_API_TOKEN. Replicate disables tokens it finds committed to public GitHub repositories.

Replicate key types

TypePrefixSecret?ScopeExpiry
API token
You can create several named tokens for different apps or environments.
r8_YesYour Replicate account—

How to create a Replicate key

  1. Sign in to Replicate.
  2. Open replicate.com/account/api-tokens.
  3. Create a token with a descriptive name and copy it.

Open Replicate's key settings

Limiting what the key can do

Replicate's page describes separate named tokens per app or environment rather than permission scopes.

How to rotate a Replicate key

  1. Create a new token.
  2. Update your applications to use it.
  3. Disable or delete the old token.

How to revoke a Replicate key

  1. Open the API tokens page.
  2. Disable the token; any app using it stops working.

If your Replicate key leaked

  1. Disable the exposed token on the API tokens page.
  2. Create a new token and update your applications.
  3. Check your email; Replicate disables tokens found in public GitHub repos and emails you next steps.

Environment variables and CLI

Replicate's SDKs and docs read the key from REPLICATE_API_TOKEN.

Things that catch people out

  • Replicate scans public GitHub repositories and disables tokens it finds, so apps using a leaked token stop working.
  • Disabling a token breaks every app using it, so create the replacement first.

Using your Replicate key with AI agents

A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.

BotPassword works this way. For a Replicate key, these intents fit:

IntentWhat BotPassword does
run_withRuns a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output.
http_requestMakes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused.
rotatePartly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet.
store_secretSaves a value the agent already holds as a new vault item.
capture_secretPlanned, not built yet: will read a newly created key straight from the page or command output into the vault.

Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents

Frequently asked questions

Where do I find my Replicate API token?

At replicate.com/account/api-tokens.

What does a Replicate token look like?

It is 40 characters and starts with r8_.

What is the Replicate environment variable?

REPLICATE_API_TOKEN.

Can an AI agent use my Replicate key without seeing it?

Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with run_with, http_request, store_secret, so the agent gets the result and never the value.

Stop pasting Replicate keys into agents

BotPassword is in early access. Request an invite and we'll email you when your spot opens.