---
title: Claude Desktop with AI Gateway
description: Connect Claude Desktop to Vercel AI Gateway using Third-Party Inference. Configure the gateway endpoint, API key, model discovery, and session...
url: "https://vercel.com/docs/ai-gateway/coding-agents/claude-desktop"
last_updated: 2026-12-02
related:
  - /docs/cli/ai-gateway
  - /docs/ai-gateway/pricing
  - /docs/ai-gateway/authentication-and-byok/byok
  - /docs/ai-gateway/authentication-and-byok/api-keys
  - /docs/ai-gateway/observability-and-spend/budgets
install_vercel_plugin: npx plugins add vercel/vercel-plugin
search_with_vercel_cli: npx vercel@latest docs search "<query>"
search_kb_with_vercel_cli: npx vercel@latest kb search "<query>"
---

# Claude Desktop with AI Gateway

Connect [Claude Desktop](https://claude.ai/download) to Vercel AI Gateway using Claude Desktop's Third-Party Inference settings. Once configured, Claude Desktop routes Chat, Cowork, and Code requests through AI Gateway so you can centralize API keys, monitor token usage and spend, inspect request logs, and manage provider fallbacks in one place.

The [Vercel Command Line Interface (CLI) setup command](/docs/cli/ai-gateway#setup) configures the Claude Code CLI, not Claude Desktop, because Claude Desktop stores its inference provider in its own app settings. Configure Claude Desktop in the app first, then optionally run the Vercel CLI to copy your existing desktop sessions to the gateway identity.

## Prerequisites

Before you connect Claude Desktop to AI Gateway, you need:

- The latest version of [Claude Desktop](https://claude.ai/download) on macOS or Windows. Older versions do not include Third-Party Inference settings
- A Vercel team with [AI Gateway Credits](/docs/ai-gateway/pricing#top-up-your-ai-gateway-credits) or [bring your own key (BYOK)](/docs/ai-gateway/authentication-and-byok/byok) provider credentials configured
- An [AI Gateway API key](/docs/ai-gateway/authentication-and-byok/api-keys)

## Connect Claude Desktop to AI Gateway

- ### Get an AI Gateway API key
  Go to the [**AI Gateway**](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway\&title=Go+to+AI+Gateway) section in the Vercel dashboard sidebar and select **API keys** to create a new key. Creating a dedicated key for Claude Desktop lets you track its spend separately and set an [API key budget](/docs/ai-gateway/observability-and-spend/budgets#api-key-budgets).

  If you already ran `npx vercel@latest ai-gateway setup` for Claude Code, you can reuse that key. On macOS, print the Keychain-stored key with:
  ```bash filename="terminal"
  security find-generic-password -s 'Vercel AI Gateway' -a 'vercel-ai-gateway' -w
  ```
  On Windows and Linux, or if you ran setup with `--no-keychain`, find the key in `~/.claude/settings.json` under `env.ANTHROPIC_AUTH_TOKEN`.

- ### Enable Developer Mode in Claude Desktop
  1. Open the Claude Desktop app menu. On macOS, use the menu bar at the top of the screen. On Windows, select the menu button in the top-left corner of the window.
  2. Select **Help** > **Troubleshooting** > **Enable Developer Mode** and confirm.
  Enabling Developer Mode adds a **Developer** menu to the top app menu.

- ### Configure Third-Party Inference
  1. Select **Developer** > **Configure Third-Party Inference** from the top app menu.
  2. In the **Connection** section, set **Inference provider** to **Gateway**.
  3. In **Gateway credentials**, set **Credential kind** to **Static API key** and fill in the remaining fields:
  | Field | Value |
  | --- | --- |
  | **Credential kind** | **Static API key** |
  | **Gateway base URL** | `https://ai-gateway.vercel.sh/claude-code` |
  | **Gateway API key** | Your AI Gateway API key |
  | **Gateway auth scheme** | `bearer` (default) |

  Select **Test connection** (if shown), save your changes, and relaunch Claude Desktop.
  > **💡 Note:** The **Developer** page inside Claude Desktop's **Settings** is a different
  > screen that only manages local Model Context Protocol (MCP) servers. Open
  > **Developer** > **Configure Third-Party Inference** from the top app menu
  > instead.
  `https://ai-gateway.vercel.sh/claude-code` is AI Gateway's [Claude Code compatibility endpoint](/docs/ai-gateway/coding-agents/claude-code#claude-code-compatibility-endpoint), which implements the Anthropic Messages API. Omit `/v1` from the base URL because Claude Desktop appends `/v1/messages` automatically. Adding `/v1` produces a `404` error.

- ### Verify requests in AI Gateway
  Start a conversation and send a message in Claude Desktop. Confirm the request appears in the [AI Gateway Overview](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai-gateway\&title=Go+to+AI+Gateway) or [AI Gateway Logs](/docs/ai-gateway/observability-and-spend/logs) in the Vercel dashboard.

## Migrate existing Claude Desktop sessions

Claude Desktop stores conversation history per identity, so sessions created before you switched providers do not appear under the gateway (`Claude-3p`) identity automatically.

To bring your existing sessions across, launch Claude Desktop at least once after switching to AI Gateway so the gateway identity exists, then run:

```bash filename="terminal"
npx vercel@latest ai-gateway setup --agent claude-code
```

The command copies each existing Claude Desktop session into the gateway identity and rewrites each session's model to its matching AI Gateway model ID. Your original sessions remain untouched, and re-running the command skips sessions it already copied. See [desktop session migration](/docs/cli/ai-gateway#desktop-session-migration) for full details.

## Models and virtual models

Claude Desktop queries the `/claude-code` endpoint for available models. On this endpoint, AI Gateway lists models with a `claude-code/` prefix and adds a `[1m]` suffix to models that accept a 1M-token prompt, such as `claude-code/anthropic/claude-opus-5[1m]`. AI Gateway strips the prefix and suffix before routing, so requests bill and trace against the underlying model. Image generation models are filtered out.

Your team's [virtual models](/docs/ai-gateway/models-and-providers/virtual-models#using-a-virtual-model-with-claude-code-codex-and-other-coding-agents) appear in the `/claude-code` catalog as `claude-code/vmc/<slug>`. Select a virtual model to apply centralized provider routing, fallbacks, regional inference, zero data retention, and provider options to Claude Desktop traffic without editing client settings.

## Billing, spend limits, and disconnecting

When Claude Desktop runs in Third-Party Inference mode, requests authenticate with your AI Gateway API key rather than your claude.ai subscription:

- **AI Gateway Credits**: Vercel deducts each request from your team's credits at [AI Gateway rates](/docs/ai-gateway/pricing#ai-gateway-rates), with zero markup over provider list prices.
- **BYOK**: If your team configures provider credentials through [AI Gateway BYOK](/docs/ai-gateway/authentication-and-byok/byok), the provider bills you directly for requests served with your credentials. By default, if your provider credentials fail, AI Gateway can fall back to Vercel's provider keys and charge your credits. To prevent fallback to Vercel's keys, turn off [Fallback to Vercel Keys](/docs/ai-gateway/authentication-and-byok/byok#turn-off-fallback-to-vercel-keys). See [AI Gateway pricing](/docs/ai-gateway/pricing#bring-your-own-key-byok) for BYOK details.
- **Claude subscriptions and API credit grants**: Third-Party Inference does not draw from Claude Pro, Max, or Team subscription limits, and Claude Desktop is excluded from claimed Claude API credit grants. See [API credit eligibility](/docs/ai-gateway/coding-agents/claude-code#api-credit-eligibility).

### Limit or stop AI Gateway charges

You can cap spend or disconnect Claude Desktop from AI Gateway in three ways:

- **Cap spend**: Set an [API key budget](/docs/ai-gateway/observability-and-spend/budgets#api-key-budgets) in the Vercel dashboard. After the key crosses its limit, AI Gateway rejects subsequent requests with HTTP `402` until the budget resets or you raise it.
- **Switch back in Claude Desktop**: Open **Developer** > **Configure Third-Party Inference**, remove or change the gateway configuration, save your changes, and relaunch Claude Desktop.
- **Revoke the key**: [Delete the API key](/docs/ai-gateway/authentication-and-byok/api-keys#delete-a-key) in Vercel so AI Gateway immediately rejects further requests from that key.

## Troubleshooting

- **Enable Developer Mode is missing from the Help menu**: Update Claude Desktop to the latest version and relaunch the app.
- **Developer settings only show MCP servers**: You opened **Settings** > **Developer**. Use **Developer** > **Configure Third-Party Inference** in the top app menu instead.
- **Test connection or chat returns a `404` error**: Check that **Gateway base URL** is set to `https://ai-gateway.vercel.sh/claude-code` without a trailing `/v1`.
- **Previous conversations do not appear after switching**: Launch Claude Desktop once with AI Gateway enabled, then run `npx vercel@latest ai-gateway setup --agent claude-code` to migrate your sessions.

## Next steps

- [Set up Claude Code and the Claude Agent SDK](/docs/ai-gateway/coding-agents/claude-code) with AI Gateway
- [View usage, traces, and spend](/docs/ai-gateway/observability-and-spend/observability) in AI Gateway observability
- [Set budgets and spend alerts](/docs/ai-gateway/observability-and-spend/budgets) for your AI Gateway API keys
- [Configure BYOK](/docs/ai-gateway/authentication-and-byok/byok) to route requests through your own provider accounts
- [Connect other coding agents and chat platforms](/docs/ai-gateway/coding-agents) to AI Gateway

## Search the docs from your terminal

Search the Vercel docs and read pages as Markdown with the Vercel CLI. No login required.

```bash
# Find docs pages by keyword
npx vercel@latest docs search "environment variables"
npx vercel@latest docs search "function timeout"

# Print a docs page as Markdown, by path or URL
npx vercel@latest docs inspect <page>
```

## Search guides from your terminal

Search the Knowledge Base and read guides as Markdown with the Vercel CLI. No login required.

```bash
# Find guides by keyword
npx vercel@latest kb search "rewrites and redirects"
npx vercel@latest kb search "AI SDK streaming"

# Show the latest guides
npx vercel@latest kb

# Print a guide as Markdown, by slug or URL
npx vercel@latest kb inspect <guide>
```

---

[View full sitemap](/docs/sitemap)


If you encounter incorrect information, can’t find what you need, need a capability Vercel doesn’t currently offer, or have any other feedback to report, please do it by following the instructions at https://vercel.com/feedback.md.
