Connect Claude Desktop to AI Gateway
Connect Claude Desktop on macOS to AI Gateway with Desktop Companion and use models through a Gateway Key.
This guide explains how to connect Claude Desktop on macOS to AI Gateway with Desktop Companion.
Supported setup
Section titled “Supported setup”Claude Desktop connects to AI Gateway only with a Gateway Key. Requests are processed with the Provider credentials your administrator registered, and your own Claude subscription cannot be used. To use a personal subscription, run Claude Code from a terminal or from Companion. See Use a personal Claude subscription in the Claude Code guide.
- Companion adds one connection entry to Claude Desktop’s Third-Party Inference Gateway settings. It does not delete or overwrite other Gateway settings you created.
- The Gateway Key is not written to Claude Desktop’s settings file. Claude Desktop gets the key from Companion’s credential helper when it sends requests.
- Inference handled by Claude Desktop’s Cowork feature is outside the verified scope of this connection.
Before you begin
Section titled “Before you begin”- Install Claude Desktop on macOS.
- Install Desktop Companion and create a Profile with the Gateway Key you will use. To create a Profile, see Desktop Companion CLI. Issue the Gateway Key as described in Issue and manage Gateway Keys.
- In the project’s Models menu, check that the Claude model you want is listed. That list shows the models allowed in the project.
1. Quit Claude Desktop
Section titled “1. Quit Claude Desktop”Companion does not change settings while Claude Desktop is running, and it does not quit the app for you. Before you connect, quit Claude Desktop completely, including its background processes. Closing the window may leave the app running.
2. Choose a Profile and switch Claude Desktop
Section titled “2. Choose a Profile and switch Claude Desktop”In the Claude entry on Companion’s first screen, choose the Profile to use, select Claude Desktop as the client, and launch it.
If Claude Desktop does not use this Profile yet, a switch confirmation dialog appears. Check that the Profile name and Gateway address shown in the dialog are the ones you want, then approve. Companion points Claude Desktop’s Gateway setting at this Profile, switches Claude Desktop to use an external Gateway, and starts the app. If you cancel, no setting changes and the app does not start.
Claude Desktop reads only the one selected Gateway setting. Even if Companion has several Profiles, Claude Desktop connects with only the Profile you switched to last. Launching with another Profile shows the switch confirmation dialog again. This switch does not change the Claude Code CLI settings.
From a terminal, use the Companion CLI to make the same switch. --activate-desktop stands in for approving the dialog. If you use the dev channel app, run ai-gateway-dev instead of ai-gateway-stage.
ai-gateway-stage run claude-desktop --profile <profile-id> --activate-desktopIf a switch is needed and you run without --activate-desktop, the CLI changes no setting, does not start the app, and prints this message:
Claude Desktop does not currently apply this Profile; pass --activate-desktop to launch with itIf you applied the setting in a way that does not start Claude Desktop from Companion, start Claude Desktop yourself. The app reads the new connection setting when it starts.
3. Check the connection
Section titled “3. Check the connection”When Companion reports that the setting was applied, only the settings file has changed. Check in the app that Claude Desktop actually uses Gateway models.
- In Claude Desktop’s model picker, check that the Claude models allowed in the project are listed. Claude Desktop fetches and shows the Gateway’s model list.
- Send a short request and check that a response comes back.
The model list shows Claude model IDs that Claude Desktop recognizes. If an earlier list is still cached, new Gateway models may not appear right away.
Do not put Gateway settings in settings.json
Section titled “Do not put Gateway settings in settings.json”Do not put Gateway settings in env of ~/.claude/settings.json to connect Claude Desktop. The Code tab in Claude Desktop reads this file, but Claude Desktop signed in with an Anthropic account sets the Anthropic address itself when it launches Claude Code. ANTHROPIC_BASE_URL in the file therefore does not apply to the Code tab, and requests do not go through the Gateway.
ANTHROPIC_CUSTOM_HEADERS, on the other hand, does apply to the Code tab. If you put a Gateway Key header in it, the signed-in Code tab sends that key to Anthropic. Connect Claude Desktop only with the Companion setup in this guide. For Claude Code CLI Gateway settings, follow the Claude Code guide.
Common errors
Section titled “Common errors”| Symptom | Cause | Fix |
|---|---|---|
| Companion asks you to quit Desktop and does not change settings. | Claude Desktop is running. | Quit Claude Desktop completely, including its background processes, then check again and retry. |
| A message says the setting is managed by policy. | Managed inference or deployment settings from your organization take precedence. | Ask your administrator to review the policy. Companion does not change managed policies. |
| A message says the credential helper is unavailable. | The Companion CLI installation for this channel has a problem, so Claude Desktop cannot get the key. | Repair the Companion CLI installation, then check again. Do not put the key in Claude Desktop’s settings yourself. |
| A message says Claude Desktop was not detected. | Claude Desktop is not installed. | Install the app, then check again. Companion does not create settings when the app is missing. |
| A message says the connection Companion manages is inactive. | Another Gateway setting was selected in Claude Desktop, or the external Gateway mode was turned off. | Repeat the switch in step 2. Checking status alone does not switch automatically. |
| A message says the Desktop setting conflicts or uses an unsupported format. | The settings file was edited by hand, or Companion does not support the settings format of the installed Claude Desktop. | Review local changes, restore a valid setting, then check again. Companion does not overwrite entries it does not own. |
| A message says the launch stopped before the switch. | The switch was not approved in the confirmation dialog. | Launch again and approve the switch. |
| Gateway models do not appear in the model list. | Claude Desktop was not restarted after the setting was applied, or an earlier list is still cached. The project may also have no allowed model. | Restart Claude Desktop. Check that the model you want is in the project’s Models menu. |