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

Source: https://botpassword.com/keys/replicate
Last checked: 2026-10-25

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.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| API token | `r8_` | Yes | Your 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.

## 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 the 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

- `REPLICATE_API_TOKEN`

## Gotchas

- 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 this key with AI agents (BotPassword)

- `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.

## FAQ

### 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.

## Sources

- https://replicate.com/docs/topics/security/api-tokens
