Configure Third-Party LLM APIs in Desktop AI Coding Tools: A Local Gateway Guide
This guide explains why third-party models disappear from the model picker after a desktop AI coding client upgrade and how to restore them. It walks through a four-layer architecture built around a local protocol conversion gateway, covering developer mode, provider and model mapping configuration, upstream authentication, streaming passthrough, and end-to-end verification with curl. A troubleshooting checklist and security hardening notes help you keep keys on the gateway side and maintain a stable, pay-per-use connection to the model service of your choice.
1. Background: Why Third-Party Models “Disappear” After a Client Upgrade
Many developers have noticed that after upgrading their desktop AI coding tool to a new release, the model dropdown becomes read-only again. Third-party large models can no longer be selected, and invoking them throws protocol incompatibility or authentication errors.
This does not mean the feature was removed. The client now validates the model list and the interface protocol more strictly: officially hosted models go through a built-in channel, while third-party models require you to supply a service endpoint that conforms to the client’s message protocol.
Understanding this is the key. The desktop client accepts only one “message-style” interface shape, whereas most third-party model providers expose interfaces in their own styles. With no adapter layer between the two, the UI naturally has nothing to offer. The solution is therefore straightforward: run a protocol conversion gateway locally, translate client requests into a format the third-party interface understands, and convert the responses back.
2. Overall Architecture and Selection Criteria
The whole chain can be abstracted into four layers:
- Client layer: the desktop AI coding tool, which allows a custom endpoint once developer mode is enabled.
- Gateway layer: a locally running protocol conversion and routing service responsible for auth injection, request body rewriting, model name mapping, and streaming response forwarding.
- Provider adapter layer: adapter implementations for each vendor’s interface style (message body structure, auth headers, streaming chunk format).
- Model service layer: any cloud LLM endpoint that is OpenAI-style or uses the vendor’s own style.
When choosing a gateway, look at four things: whether it passes streaming output through, whether it supports model name mapping, whether it can store keys locally instead of writing them into the client configuration, and whether it provides request logging and error code passthrough. These four points directly determine how costly troubleshooting will be later.
3. Prerequisites
- Update the desktop client to the latest stable version to avoid protocol validation defects in older releases.
- Prepare a local gateway tool or a minimal adapter service of your own, listening on a separate port on the loopback address (for example, a non-privileged high port such as 15721) to avoid conflicts with system services.
- Prepare the target provider’s endpoint URL, key, and model identifier. Keep the key only in the gateway configuration or in environment variables.
Example environment variables:
export GATEWAY_HOST=127.0.0.1export GATEWAY_PORT=15721export UPSTREAM_BASE_URL="https://your-upstream-endpoint"export UPSTREAM_API_KEY="sk-********"export MODEL_MAP="claude-sonnet-4=your-model-id"
4. Step 1: Enable Developer Mode
Developer mode is a prerequisite for custom endpoints to take effect. The typical path is: open the help and troubleshooting entry in the client’s top menu and choose to enable developer mode; a dialog warns that the mode allows access to third-party models, and the client restarts automatically after you confirm; once the developer option appears in the menu bar after the restart, the step is done.
If the menu does not appear after the restart, check three things first: whether the client was installed with read-only permissions so the configuration write failed; whether the system blocked listening on the loopback port; whether a configuration pushed by an enterprise policy is overriding the local setting.
5. Step 2: Configure the Provider and Model Mapping on the Gateway
This is the step where mistakes are most likely, so proceed in the order “connect first, then map, then tune.”
- Add a provider entry. Choose the custom type and fill in the upstream base URL and key. Make sure whether the base URL already contains a version path segment; duplicating or omitting it leads to 404.
- Configure model mapping. The model name in the client request often differs from the real upstream model identifier, so an explicit mapping is required; otherwise you get “model does not exist” errors. Use a clear one-to-one mapping and avoid wildcards that can cause misrouting.
- Set timeouts and retries. Long-context code tasks take considerable time, so raise the read timeout to the hundreds-of-seconds range; enable retries only for idempotent connection errors to avoid duplicate billing.
- Start the local router. After starting it, leave the client alone and run one end-to-end check from the command line.
Example verification command (replace the placeholders with your actual local values):
curl http://127.0.0.1:15721/v1/messages \-H "Content-Type: application/json" \-H "Authorization: Bearer $UPSTREAM_API_KEY" \-H "anthropic-version: 2023-06-01" \-d '{"model": "your-model-id","max_tokens": 64,"messages": [{"role": "user", "content": "ping"}]}'
The response body should contain content blocks and a stop reason field. A 401 means the key was not injected or the header name does not match; a 404 usually points to a wrong base URL or path concatenation; a 400 complaining about an invalid field typically means the message body structure was not converted; if the command hangs with no response, check whether the streaming chunk format is being passed through correctly.
6. Step 3: Point the Client at the Local Gateway
In the custom model endpoint configuration under the developer options, set the address to the gateway’s local messages path, put a placeholder value in the key field (the real key is injected by the gateway), and enter the name on the left side of the mapping as the model name. Save, reload the window, and the new entry should appear in the model list.
If the list is still empty, check in this order: whether the gateway process is alive and listening; whether the client is using a system proxy that forwards loopback requests outward (add the loopback address to the proxy exclusion list); whether the port is occupied by another process.
7. Common Problems and Troubleshooting Checklist
- Streaming output stops midway: usually the upstream chunk format does not match what the client expects, so the gateway needs to reassemble chunks.
- Tool calls unavailable: the client depends on specific tool call fields, and the adapter layer must convert those fields in both directions.
- Long-context errors: confirm the upstream context limit and apply truncation or segmentation on the gateway side.
- Out-of-control cost: enable local per-request and usage-based counting logs and set a per-session token cap.
8. Security and Compliance Hardening
Store keys only on the gateway side and restrict configuration file permissions to the current user; have the gateway listen on loopback only and never expose it externally; for production or team environments, you can combine general capabilities such as object storage, logging, and monitoring alerts from Baidu AI Cloud to back up configuration, audit calls, and alert on anomalies, forming a sustainable operations loop.
9. Summary
Third-party models becoming unselectable after a client upgrade is essentially an adaptation gap at the protocol and validation level. With these four steps — developer mode, a local protocol conversion gateway, explicit model mapping, and loopback verification — you can freely choose your model service while keeping the desktop client’s native interaction experience, with pay-per-use billing and a stable direct connection.
