# Together AI API keys: find, store, rotate, and use them safely with AI agents

Source: https://botpassword.com/keys/together-ai
Last checked: 2026-11-08

Together AI API keys are created on a project's API keys page (`api.together.ai/settings/projects/~current/api-keys`), can be given an expiration date, and are shown only once. Send the key as `Authorization: Bearer $TOGETHER_API_KEY`; the Python and TypeScript SDKs read `TOGETHER_API_KEY` automatically. A revoked Together AI API key stops working within about five minutes and cannot be restored.

## Key types

| Type | Prefix | Secret | Scope | Expiry |
|---|---|---|---|---|
| Project API key | — | Yes | Full access to the project it was created in, including spending its credits | Optional; set a preset or custom date at creation, or later with **Set expiration** |
| Legacy key | — | Yes | The organization's default project | Cannot be given an expiration date |
| Vercel integration key | — | Yes | The default project; one key per linked Vercel project | — |

## How to create a Together AI key

1. Sign in to Together AI and open the project the key is for.
2. Go to the project's [API keys](https://api.together.ai/settings/projects/~current/api-keys) settings.
3. Select **Create API Key**, enter a descriptive name such as `prod-inference`, and optionally choose **Set an expiration date**.
4. Select **Create** and copy the key immediately; it is not shown again.
5. Export it as `TOGETHER_API_KEY`.

## Limiting what the key can do

Together AI API keys are scoped to one project, and anyone holding a key has full access to that project. Use separate projects to separate environments, and set expiration dates on temporary or test keys. Project admins and editors can both create and revoke keys.

## How to rotate a Together AI key

1. Create a new project key, with an expiration date if it suits your rotation schedule.
2. Move every application and secret store to the new key.
3. Check the old key's **Last used** column until it stops receiving traffic.
4. Open the old key's three-dot menu, select **Revoke key**, type `I understand` and select **Revoke**.

## How to revoke a Together AI key

1. Open the project's [API keys](https://api.together.ai/settings/projects/~current/api-keys) settings.
2. Open the three-dot menu on the key's row and select **Revoke key**, or tick several keys and select **Revoke N keys** (up to 100 at once).
3. Type `I understand` and select **Revoke**. The dialog warns if the key was used in the past 24 hours.
4. The key stops working within about five minutes, and revocation cannot be undone.

## If the key leaked

1. Revoke the exposed Together AI API key from its row menu with **Revoke key**.
2. Create a new project key and deploy it.
3. Check the **Last used** column and the organization's billing for usage you do not recognise, since a key can spend the project's credits.
4. Revoke any other keys that are unused, including legacy keys.

## Environment variables

- `TOGETHER_API_KEY`

## Gotchas

- New Together AI API keys are shown only once, so save the value when you create it.
- Revocation takes about five minutes to take effect, so a leaked key can still be used briefly.
- Disconnecting a Vercel integration does not revoke its key; revoke it on the API keys page.
- The Together CLI prefers a `tg login` session over `TOGETHER_API_KEY`, so scripts and CI should pass the key explicitly.

## 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.
- `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 Together AI API key?

Create one on your project's API keys page at `api.together.ai/settings/projects/~current/api-keys`. Existing keys cannot be shown again.

### Which environment variable does Together AI use?

`TOGETHER_API_KEY`, read automatically by the Python and TypeScript SDKs.

### How do I revoke a Together AI API key?

Open the key's three-dot menu, select **Revoke key**, type `I understand` and confirm. It stops working within about five minutes.

### Do Together AI API keys expire?

Only if you set an expiration date, at creation or later with **Set expiration**. Legacy keys cannot be given one.

### Why does my Together AI API key return 401?

Together returns 401 when the API key is missing or invalid; check the key and the `Authorization: Bearer` header.

### Can an AI agent use my Together AI 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://docs.together.ai/docs/quickstart
- https://docs.together.ai/docs/api-keys-authentication
- https://docs.together.ai/docs/roles-permissions
- https://docs.together.ai/docs/projects
- https://docs.together.ai/docs/error-codes
- https://docs.together.ai/reference/cli/auth
