> ## Documentation Index
> Fetch the complete documentation index at: https://docs.together.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> Create, manage, and authenticate with project-scoped API keys.

Together AI uses API keys to authenticate requests. Keys are scoped to [projects](https://docs.together.ai/docs/projects.md), meaning a key only has access to the resources within its project.

## Create an API key

Create independent API keys for separate use cases, systems, or workloads. For example, one for production, one for development, one for CI/CD, and one for inference.

**1. Open the project**

Navigate to the project you want to create a key for.

**2. Open API key settings**

Go to the project's [API keys settings](https://api.together.ai/settings/projects/~current/api-keys).

**3. Create the key**

Select **Create API Key** and enter a name. To make the key expire automatically, select **Set an expiration date** and choose a preset or custom date. Then select **Create**.

**4. Copy the key**

Copy the key immediately. It won't be shown again.

> [!WARNING]
>
> New API keys are displayed only once at creation. Save them in a secure location, such as a secrets manager, immediately. If you lose a key, you'll need to create a new one.

## Revoke API keys

A revoked key stops working within about five minutes and can't be restored. Before you revoke a key, check the **Last used** column in the project's [API keys settings](https://api.together.ai/settings/projects/~current/api-keys). It shows how long ago the key was last used, or **Never**. Hover the info icon for the exact date.

* **One key:** Open the three-dot menu on the key's row and select **Revoke key**.
* **Several keys:** Select each key's checkbox, or the header checkbox to select every listed key. Then select **Revoke *N* keys**. You can revoke up to 100 keys at once, and you can't select legacy or expired keys.

To confirm, enter `I understand` and select **Revoke**. If the key was used in the past 24 hours, the dialog warns you first. Revoked keys show a **Revoked** status and are hidden by the default **Status: Active** filter.

## Best practices

* **Name your keys descriptively** (for example, `prod-inference`, `ci-pipeline`, `dev-local`) so you can identify and rotate them.
* **Set expiration dates** for keys used in temporary or testing contexts. Select **Set an expiration date** when creating a key, or **Set expiration** in the three-dot menu next to an existing key. To keep a key that's scheduled to expire, select **Cancel expiration** from the same menu.
* **Rotate keys regularly** and [revoke](#revoke-api-keys) any that are no longer in use.
* **Never commit keys to source control:** Use environment variables or a secrets manager.
* **Treat keys as secrets:** Anyone holding a key has full access to its project's resources and can spend your credit balance, which auto-recharge tops back up. If you suspect a key has leaked, revoke it immediately and create a new one.

## Set as an environment variable

The Together Python and TypeScript SDKs read your key from the `TOGETHER_API_KEY` environment variable. Set it in your shell:

```bash macOS / Linux theme={null}
export TOGETHER_API_KEY="your_api_key"
```

```powershell Windows (PowerShell) theme={null}
$env:TOGETHER_API_KEY="your_api_key"
```

If your project loads environment variables from a `.env` file, add it there:

```dotenv .env theme={null}
TOGETHER_API_KEY=your_api_key
```

> [!TIP]
>
> To authenticate the Together CLI, [log in with `tg login`](https://docs.together.ai/reference/cli/auth) instead of setting an API key.

## Authenticate a request

Include your API key in the `Authorization` header of every API request:

```bash theme={null}
curl https://api.together.ai/v1/chat/completions \
  -H "Authorization: Bearer $TOGETHER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "meta-models/Muse-Glimmer-30B",
    "messages": [{"role": "user", "content": "Hello"}]
  }'
```

## Project key scoping

API keys are scoped to projects:

* A key created in project A can only access resources in project A.
* Keys persist even if the collaborator who created them is removed from the project.
* Both project admins and member-role collaborators can create and revoke keys.

This means you can safely share a project API key with a CI/CD pipeline or external collaborator without giving them access to resources in other projects.

> [!NOTE]
>
> Keys created before multi-project support was enabled are scoped to your organization's default project.

## Playground

The [Together AI playground](https://api.together.ai/playground/) recognizes all API keys associated with your account. When you use the playground, it shows available models across all your keys and projects.

## Cost analytics and usage

Use API key IDs to segment usage and cost by key and workload. The `api_key_id` field is supported for inference requests, so you can track which keys are driving spend in your [project's cost analytics](https://api.together.ai/settings/projects/~current/cost-analytics).

## Limitations

**No per-key usage limits:** You can't cap spend or rate-limit individual API keys. Usage limits apply at the organization level.

## Vercel integration

When you connect a Vercel project from [Integrations settings](https://api.together.ai/settings/integrations), each linked Vercel project gets its own dedicated API key. Together creates the key in your organization's default project and sets it as the `TOGETHER_API_KEY` environment variable in the Vercel project.

Manage or revoke these keys from the default project's [API keys settings](https://api.together.ai/settings/projects/~current/api-keys), like any other key. Disconnecting a Vercel project removes the environment variable from Vercel but doesn't revoke the key.

> [!NOTE]
>
> This is the Together AI console Vercel integration, not the npm [AI SDK provider](https://docs.together.ai/docs/using-together-with-vercels-ai-sdk.md).

## Legacy API keys

Your organization may have a legacy API key scoped to its default project. It appears in that project's [API keys settings](https://api.together.ai/settings/projects/~current/api-keys) with a **Deprecated** badge.

Legacy keys are deprecated, and you should **avoid using them in production.** These keys can't be scoped to a specific project or workload. Use [project-scoped API keys](#create-an-api-key) instead.

Legacy keys can't be regenerated, renamed, or given an expiration date. To replace a legacy key, create a project-scoped key, move your applications to it, then open the three-dot menu on the legacy key's row and select **Revoke key**.

## Related resources

> [card] [Projects](https://docs.together.ai/docs/projects.md)
>
> Understand how API keys are scoped to projects.

> [card] [Roles and permissions](https://docs.together.ai/docs/roles-permissions.md)
>
> See who can create and manage API keys.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.