跳到正文
DEV Community· ModelFild·· 2 小時前AI 評分59

Claude Desktop 與 Claude Code CLI 的 Gateway 設定有何不同

Claude Desktop vs Claude Code CLI: Two Different Gateway Setups

AI 導讀

Claude Desktop 的 Code 分頁與 Claude Code CLI 需要分別設定 Gateway,前者使用應用程式內的第三方推理設定,後者則透過環境變數配置。

正文

Changing a terminal environment variable can route Claude Code CLI through a gateway. It does not configure the Code tab inside the Claude desktop app. Those are separate configuration paths, and confusing them can leave you using the wrong account.

Disclosure: this tutorial comes from the ModelFold team. It uses our gateway as the example. The Windows screenshots document configuration and the Gateway state; they are not evidence of a completed paid coding session.

Choose the right surface

This guide covers the desktop app's Code tab and the CLI. It does not add third-party API keys to ordinary claude.ai web chat or the mobile app.

For the desktop app, use the third-party inference form. For the CLI, use environment variables. ModelFold's Windows walkthrough now includes real screenshots of the relevant menus.

Configure the desktop app on Windows

Install the official Claude desktop app using the download link in the walkthrough. You will also need your own ModelFold API key from Console → API Keys.

  1. Open the application menu at the top left.
  2. Choose Help → Troubleshooting → Enable Developer Mode. Let the app restart.
  3. Open Developer → Configure Third-Party Inference.
  4. Under Connection, choose Gateway and enter:
Inference provider: Gateway
Gateway base URL: https://modelfold.ai/anthropic
Credential kind: Static API key
Gateway API key: <your raw mf- key>
Gateway auth scheme: bearer

Click Apply Changes and allow the app to relaunch. Follow a Save & Restart prompt if it appears. These are application settings; putting the same information in a terminal does not configure this desktop surface.

Actual Windows gateway form, with the API key masked

The screenshot uses a Chinese application UI. The field values above provide the English equivalents.

Keep the base URL at /anthropic. The client appends /v1/messages; adding /v1 yourself can produce an incorrect path. Paste the key without Bearer because the selected authentication scheme adds that prefix.

After restarting, the Code page should identify the connection as Gateway. This checks the selected configuration, not whether every model request will succeed.

Actual Windows Code page showing the Gateway connection state

Configure the CLI separately

If you use Claude Code in a terminal, the configuration is different. The following PowerShell example assumes you have already set MODELFOLD_API_KEY privately in that shell. Do not paste a real key into an article, repository, or screenshot.

# These variables affect the CLI launched from this PowerShell session.
$env:ANTHROPIC_BASE_URL = "https://modelfold.ai/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = $env:MODELFOLD_API_KEY

# Read-only model discovery; this does not generate an answer.
curl.exe -sS "https://modelfold.ai/anthropic/v1/models" `
  -H "Authorization: Bearer $env:MODELFOLD_API_KEY"

# Use an actual id returned above, not a guessed model alias.
claude --model "<model-id-from-the-response>"

Replace the model placeholder before running the final command. Prefer one credential method; an old ANTHROPIC_API_KEY in your environment can make the configuration harder to reason about. In the CLI, /status helps check the base URL and authentication source. PowerShell users should use curl.exe, since curl may resolve to a PowerShell alias.

Separate configuration checks from paid tests

A models response confirms discovery and authentication. The Gateway label confirms the desktop configuration. Neither proves a completed generation.

When you decide to test a real coding request, use a small local folder and a short task, review the requested file/tool permissions, and check the usage record in your ModelFold account afterward. Generation consumes credits; this article did not run a paid desktop request.

If you see 401, check for a revoked key or a duplicated Bearer prefix. For 404, check the base path. A Windows Virtual Machine Platform warning is a separate workspace prerequisite, covered in the Windows walkthrough. Organization-managed settings may prevent local changes.

Anthropic documents the desktop gateway configuration in its gateway reference and in-app configuration guide. Use those for client changes; use the ModelFold CLI guide for our endpoint and authentication details. Do not assume cloud sessions or ordinary chat use this local configuration.

來源:DEV Community · dev.to