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

# Connect Claude to Agents With a Token or API Key

> Let agents call Claude with your Claude plan via claude setup-token, or a Console API key. The gateway injects it, so agents never see the credential.

## Overview

Buckle injects your Anthropic credential into requests to `api.anthropic.com` automatically. Agents make standard requests to the Anthropic API; the gateway adds the credential before forwarding.

This lets agents use Claude models (Claude Opus, Sonnet, Haiku) without ever seeing or handling your credential directly. For routing to Claude via Google Cloud instead, see [Vertex AI](/docs/integrations/vertex-ai.md). For a comparison of supported LLM providers, see [LLM Providers](/docs/integrations/llms.md).

## What you will set up

* A Claude credential in Buckle: a subscription token from `claude setup-token` or a Claude Console API key
* Automatic injection into the right header on requests to `api.anthropic.com`
* Per-agent access to the credential, with optional organization rules

## Choose how to connect

| Option | Best for | What you paste | Starts with |
| - | - | - | - |
| **Claude subscription token** | You have a Claude Pro, Max, Team, or Enterprise plan | The token `claude setup-token` prints | `sk-ant-oat` |
| **API key** | Pay-as-you-go API billing in the Claude Console | A key from the Claude Console | `sk-ant-api` or `sk-ant-usr` |

Both go into the same field, and Buckle detects which one you pasted:

| Credential | Header | How it's injected |
| - | - | - |
| Subscription token (`sk-ant-oat...`) | `Authorization` | `Bearer {token}` |
| API key (`sk-ant-api...`, `sk-ant-usr...`, and other `sk-ant-` keys) | `x-api-key` | Raw value |

Admin API keys (`sk-ant-admin...`) can't call Claude models, so Buckle won't use them.

## Where to paste it

In the Buckle dashboard, open your agent's **Agent settings** page (under **More** in the sidebar), click **Add LLM key** in the **Model** block, and choose **Anthropic**. Paste your token or key into **Secret value** and click **Add Secret**. **Need help?** in the window opens this page.

![Buckle Anthropic key window with the Name field, the Secret value field, the hint 'From claude setup-token, or an API key from the Claude Console', Advanced settings, and Need help?, Cancel and Add Secret buttons.](https://mintcdn.com/onecli-17d3f772/hJP3XqgFsBDnXHKy/images/integrations/anthropic/01-buckle-anthropic-dialog.png?fit=max\&auto=format\&n=hJP3XqgFsBDnXHKy\&q=85\&s=fb980b30e003bc27351fd3b136f9967f)

The Anthropic key window in Buckle.

## Option 1: Claude subscription token

Use this if you pay for a Claude plan. Usage counts against your plan instead of API billing. The free Claude plan doesn't include Claude Code, so it can't create a token.

**1. Open a terminal**

* **macOS:** press `Cmd + Space`, type **Terminal**, and press Enter.
* **Windows:** press the Windows key, type **PowerShell**, and press Enter.
* **Linux:** open your terminal app (often `Ctrl + Alt + T`).

**2. Install Claude Code**

Paste the command for your system and press Enter. It shows no progress while it downloads, so give it a minute.

**macOS, Linux, or WSL:**

```bash theme={null}
curl -fsSL https://claude.ai/install.sh | bash
```

**Windows PowerShell:**

```powershell theme={null}
irm https://claude.ai/install.ps1 | iex
```

When it finishes you'll see **Installation complete!**. If it also shows **Setup notes** saying `~/.local/bin is not in your PATH`, do the next step.

![Terminal output of the Claude Code installer: Claude Code successfully installed, version and location, a Setup notes warning that \~/.local/bin is not in your PATH with the command to fix it, and Installation complete.](https://mintcdn.com/onecli-17d3f772/hJP3XqgFsBDnXHKy/images/integrations/anthropic/02-terminal-install.png?fit=max\&auto=format\&n=hJP3XqgFsBDnXHKy\&q=85\&s=a85f7b1831342275b21cee1ea2655147)

The installer finished. The Setup notes mean the claude command isn't on your PATH yet.

**3. Make sure the claude command works**

Open a **new** terminal window, then run:

```bash theme={null}
claude --version
```

If you see a version number, such as `2.1.296 (Claude Code)`, skip to the next step. If you see `command not found` or `not recognized`, add the install folder to your PATH once, for your shell:

**macOS (zsh, the default):**

```bash theme={null}
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
```

**Linux (bash):**

```bash theme={null}
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
```

**Windows PowerShell:**

```powershell theme={null}
$currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
[Environment]::SetEnvironmentVariable('PATH', "$currentPath;$env:USERPROFILE\.local\bin", 'User')
```

On Windows, close PowerShell and open a new window after this. Then run `claude --version` again.

![Terminal running the PATH command for bash, then claude --version printing 2.1.296 (Claude Code).](https://mintcdn.com/onecli-17d3f772/hJP3XqgFsBDnXHKy/images/integrations/anthropic/03-terminal-path-version.png?fit=max\&auto=format\&n=hJP3XqgFsBDnXHKy\&q=85\&s=486ff962bbae62dca808c8e363114921)

After the PATH fix, claude --version prints the version.

> [accordion] Used an Anthropic API key or proxy on this computer before?
>
> Leftover environment variables can make Claude Code use the wrong account. Clear them in the terminal you'll use for the next step:
>
> **macOS or Linux:**
>
> ```bash theme={null}
> unset ANTHROPIC_API_KEY ANTHROPIC_AUTH_TOKEN ANTHROPIC_BASE_URL
> ```
>
> **Windows PowerShell:**
>
> ```powershell theme={null}
> Remove-Item Env:ANTHROPIC_API_KEY, Env:ANTHROPIC_AUTH_TOKEN, Env:ANTHROPIC_BASE_URL -ErrorAction SilentlyContinue
> ```
>
> If they come back in every new terminal, delete the matching `export` lines from `~/.zshrc` or `~/.bashrc`. On Windows, remove them under **Edit the system environment variables** > **Environment Variables**.

**4. Generate the token**

Run:

```bash theme={null}
claude setup-token
```

A browser window opens. Sign in to the Claude account that has your plan and approve. If the browser doesn't open, copy the link the terminal shows into your browser, and paste the code it gives you back into the terminal.

![Terminal running claude setup-token: Welcome to Claude Code, a note that it sets up a long-lived (1-year) auth token and needs a Claude subscription, a sign-in link, and a prompt to paste the code.](https://mintcdn.com/onecli-17d3f772/hJP3XqgFsBDnXHKy/images/integrations/anthropic/04-terminal-setup-token.png?fit=max\&auto=format\&n=hJP3XqgFsBDnXHKy\&q=85\&s=c1f8016b23c1c9ca7b29967312f347bf)

claude setup-token asks you to sign in with your Claude account.

When you approve, the terminal prints a long token that starts with `sk-ant-oat`. Copy all of it. The token is valid for one year.

> [!WARNING]
>
> Treat this token like a password. Anyone who has it can use your Claude plan. Don't paste it into chats, tickets, or code.

**5. Paste it into Buckle**

Paste the token into the Anthropic window as described in [Where to paste it](#where-to-paste-it).

## Option 2: API key from the Claude Console

Use this if you pay for API usage in the Claude Console. You don't need a terminal.

**1. Create an API key**

Open [Claude Console API keys](https://platform.claude.com/settings/keys) and sign in. Click **Create Key**, name it `Buckle`, and copy the key. It starts with `sk-ant-api` or `sk-ant-usr` and is shown only once.

Your Console organization needs billing set up (credits or a payment method), or requests are refused.

**2. Paste it into Buckle**

Paste the key into the Anthropic window as described in [Where to paste it](#where-to-paste-it).

## Troubleshooting

> [accordion] claude setup-token says a subscription is required
>
> Your Claude account is on the free plan, which doesn't include Claude Code. Upgrade to Pro, Max, Team, or Enterprise, or use Option 2 with an API key.

> [accordion] Buckle says the value looks wrong or has spaces
>
> Copy the whole value again, with no spaces or line breaks. Tokens copied from a narrow terminal window can wrap onto a second line; paste the token into a text editor first to make sure it's on one line.

> [accordion] The key shows a warning in the Model block
>
> **Key rejected** means Anthropic refused the key when an agent used it: it was revoked, or the subscription token expired. **Billing issue** or **Rate limited** means the plan's usage limit was reached or the Console account has no credits. Fix it in the Claude Console, or generate a new token and update the key with the pencil icon.

## How it works

1. Your credential is encrypted and stored by Buckle (AES-256-GCM at rest)
2. When an agent sends a request to `api.anthropic.com`, the gateway intercepts it
3. The gateway injects the credential into the right header
4. The request is forwarded to Anthropic

Agents never see the raw credential. If you rotate it, update it in the dashboard and all agents pick up the new one automatically.

## Controlling access

Access is per agent: [attach](/docs/guides/agent-access.md) the key to each agent that needs it. An agent without the grant can't use it at all. Organization [rules](/docs/guides/rules.md) add guardrails on top: rate-limit requests, restrict agents to specific models by blocking certain paths, or flag high-cost operations for manual approval. Everything is checked before credential injection, so a blocked request never reaches Anthropic.

## FAQ

> [accordion] How do I get a token with claude setup-token?
>
> Install Claude Code, run `claude setup-token`, and approve in the browser with the Claude account that has your plan. The terminal prints a token that starts with `sk-ant-oat` and is valid for one year. See [Option 1](#option-1-claude-subscription-token) above, or the full [claude setup-token guide](/docs/guides/claude-setup-token.md).

> [accordion] Should I use a subscription token or an API key?
>
> Use a subscription token if you pay for a Claude Pro, Max, Team, or Enterprise plan, so usage counts against the plan. Use a Console API key for pay-as-you-go API billing. Both go into the same field, and Buckle detects which one you pasted.

> [accordion] How do I rotate or replace my Anthropic credential?
>
> Generate a new token with `claude setup-token`, or create a new key in the Claude Console. Then update the key in the **Model** block of the agent's **Agent settings** page with the pencil icon. All agents pick up the new credential automatically.

> [accordion] How do I keep my Claude key out of the agent's context?
>
> Store it in Buckle instead of setting `ANTHROPIC_API_KEY` in the agent's environment. The gateway injects the credential at the proxy, so the agent never holds it and can't leak it. See [How it works](/docs/how-it-works.md).

> [accordion] Can I limit which agents use Claude?
>
> Yes. [Attach](/docs/guides/agent-access.md) the key only to agents that need it. Add [rules](/docs/guides/rules.md) to rate-limit requests, restrict models by blocking paths, or require approval for high-cost operations.


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