Skip to main content
Use a DGrid Model API Key for model requests. A Management API Key is an administrative credential and cannot be used for this tutorial. Check that your key has available credits and access to the selected model.
Connect Claude Code to DGrid with your DGrid API key, the gateway URL, and a Claude model available to your key. This guide covers macOS Terminal first, followed by an alternative setup in the Claude desktop app’s Code tab. The example model is anthropic/claude-opus-5.5. Use its complete DGrid model ID, including anthropic/. You can substitute another available Claude model throughout the guide.

Before you start

  • A macOS computer with an internet connection. The Terminal commands below use Zsh, the default macOS shell.
  • A DGrid account with available credits and access to your chosen Claude model.
  • For the npm installation method: Node.js 22 or later and npm. Installation instructions are included below.
The CLI screenshots show Claude Code 2.1.306. Menus and model availability may differ in other versions. The desktop setup is independent: you can follow that section without completing the CLI installation.

Step 1 Create a DGrid API key and select a model

  1. Sign in to DGrid and open API Keys.
  2. Click Create New Key, name it, and create the key.
  3. Copy the key for the configuration steps below. Keep the full key out of screenshots and shared files.
  4. In DGrid’s model list, find an available Claude model and copy its complete model ID. This guide uses anthropic/claude-opus-5.5.
The connection settings are: Do not add /v1 or /v1/messages to the base URL. Claude Code adds the Messages API path when sending requests.

Step 2 Install Claude Code

If Claude Code is already installed, run claude --version and continue to Step 3 if it prints a version number.

Install with npm

First check whether Node.js and npm are available:
If either command is missing, or Node.js is older than 22, install the current LTS version from the Node.js download page. Choose the macOS installer, which includes npm. Open a new Terminal window after installation and run the two commands again.Install Claude Code into your user directory:
Add the installation directory to this terminal’s PATH and check the version:
No sudo is needed for this user-directory installation. To make the PATH setting available in new terminals, add the same export PATH line to ~/.zshrc with a text editor.

Alternative: native installer

You can instead use the official native installer. This method does not require a separate Node.js installation:
After installation, open a new terminal and check claude --version. If the command is unavailable, add ~/.local/bin to PATH using the command above. Choose one installation method. If the script URL returns HTML or fails to download, use the npm method after installing Node.js.

Step 3 Configure DGrid in the current terminal

Run this block in Zsh. Its final command prompts for the key without displaying your input:
At Paste your DGrid API key (hidden):, paste your DGrid API key and press Enter. The terminal returns to its prompt; the key remains hidden.Continue in this same terminal so Claude Code inherits the variables. These settings apply to this terminal session. For a new terminal, repeat this step or use the optional project settings below.If you previously configured another provider, its settings may still apply. An unset command removes a shell variable but does not remove an entry from a settings file. Check the effective connection in Step 5; see Troubleshooting if another credential is detected.

Step 4 Start Claude Code

Create a separate folder for your first session, then start Claude Code with the complete DGrid model ID:
If Claude Code asks whether you trust this folder, check the path and select Yes, I trust this folder for the folder you just created. Complete any first-launch appearance prompts.

Step 5 Check the active connection

Inside Claude Code, enter:
The Status tab should show:
Claude Code Status showing the DGrid URL, token source, and selected model

Claude Code Status showing the DGrid URL, token source, and selected model

If you chose another Claude model, check for that complete model ID instead. Press Esc to return to the conversation.

Step 6 Send your first message

Enter:
Press Enter and wait for the reply:
A successful reply in Claude Code Terminal

A successful reply in Claude Code Terminal

You can now continue using Claude Code through DGrid. To view usage, open DGrid’s request history and find the corresponding model and request time. A completed request is marked Success.
A completed Claude model request in DGrid

A completed Claude model request in DGrid

Token counts and charges depend on the request. The screenshot is one example, including its cache-write usage.

Optional: save settings for this project

To reuse the connection without entering shell variables each time, configure .claude/settings.local.json inside your project. Before creating it, add .claude/settings.local.json to the project’s .gitignore so the credential stays out of version control.Create or edit the local settings file, replacing the placeholder with your DGrid key:
Merge these fields with any existing local settings. This stores the key in a local file; keep that file private. In a new terminal, enter the project folder and run claude. Use /status to check the active settings again. See the official gateway settings guidance for configuration scopes.

Troubleshooting

The terminal says command not found or permission denied

Check which command the shell finds:
For the user-directory installation above, make sure ~/.local/bin is on PATH. You can check the installed launcher directly:
If it is missing or cannot run, review the installer output and complete a successful installation before configuring the gateway. See Claude Code installation troubleshooting.

Claude Code detects another API key or shows the wrong gateway

Existing user or project settings can contain provider variables. If a first-launch prompt offers an old ANTHROPIC_API_KEY you do not intend to use, choose No for that key, then run /status to confirm the DGrid URL, the ANTHROPIC_AUTH_TOKEN source, and your model. If the status is wrong, review the env entries in ~/.claude/settings.json, .claude/settings.json, and .claude/settings.local.json, along with any provider-switching tool you use. Settings-file values can override shell exports. Change the relevant provider fields or use the project-local configuration above, preserving unrelated settings. Restart the session and check /status again.

A request fails with an authentication or model error

Check the DGrid key, available credits, and access to the selected Claude model. Use the complete DGrid model ID rather than assuming a built-in model alias matches DGrid’s catalog. Re-enter the key if necessary without displaying it.

The desktop app reports a gateway error

Open Details and inspect the request URL, HTTP status, response message, and probedModel if present. The connection check can use a model different from the one selected for your chat. Check that the key has access to the reported model. An HTTP 500 with upstream_error does not by itself establish whether the key, model route, or upstream service caused the failure. Confirm the saved connection settings and model access, then retry. If the error persists, provide DGrid support with the request time and error details, excluding the API key.

The desktop app does not show the expected model

Reopen the third-party inference settings and confirm the DGrid gateway and key were applied. Check that the model is available to that key. Desktop model lists can come from gateway discovery or an explicit configured list; see the official gateway model configuration.