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
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| API token You can create several named tokens for different apps or environments. | r8_ | Yes | Your Replicate account | — |
How to create a Replicate key
- Sign in to Replicate.
- Open
replicate.com/account/api-tokens. - Create a token with a descriptive name and copy it.
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
- Create a new token.
- Update your applications to use it.
- Disable or delete the old token.
How to revoke a Replicate key
- Open the API tokens page.
- Disable the token; any app using it stops working.
If your Replicate key leaked
- Disable the exposed token on the API tokens page.
- Create a new token and update your applications.
- 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:
| Intent | What BotPassword does |
|---|---|
run_with | Runs 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_request | Makes 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. |
rotate | Partly 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_secret | Saves a value the agent already holds as a new vault item. |
capture_secret | Planned, 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.