Dify custom provider won't validate: the fixes

Dify refusing to save an OpenAI-API-compatible model is the API Base URL, the key, the Model Name or its type. Read the code in the error to find the field.

Checked 2026-11-22

·All fixes·Models

When Dify will not save an OpenAI-API-compatible model for the gateway, the refusal comes from the credential check Dify runs on save, and it traces back to one of four places: API Base URL, API Key, Model Name, or the model type the entry is added under. This page is the troubleshooting companion to the Dify setup guide, which walks through the working form field by field; here you start from the failed save and find the field behind it. The base is https://api.uplinkswitch.com/v1.

Read the error Dify shows

Dify sends a short test request when you save a model, and a failed test is reported with its status code, often with the response body as well. Look for the status and the code in that text before you edit anything, because each code points at one field:

Code in the errorField to fix
404 route_not_foundAPI Base URL carries a path after /v1
401 invalid_api_keyAPI Key is empty, mistyped or revoked
403 scope_deniedThe key's allowlist leaves out this model
404 model_not_foundModel Name is not a catalog id
402The balance or the key's budget is spent

Other gateway statuses carry their own code in the body too: a 429 is a rate limit, and a 502 or 503 means the model side failed or was busy, so retry the save after a pause. A refused connection or a DNS failure points at the network between Dify and the gateway, while a timeout alone does not tell you whether the request arrived.

API Base URL ends at /v1

The provider appends the route for the mode you chose, so the field takes the gateway root and nothing after it. With /chat/completions pasted on the end, the test request lands on a doubled path and the gateway replies 404 route_not_found, which Dify reports as a failed validation that reads like a model problem. Enter https://api.uplinkswitch.com/v1 exactly, with no trailing slash.

On a self-hosted Dify the save is checked from the Dify server, not from your browser. A corporate proxy, or a container with no outbound access, fails the save even when the same URL answers from your laptop.

API Key and the 401

A 401 with invalid_api_key means the base resolved and the key did not. The message separates the two usual cases: No API key was sent. for an empty field, and The API key is not valid. for a wrong value. Paste a current sk-uplink-live-... key. A key restricted to other models still authenticates and fails with 403 scope_denied instead, so a 401 is never a permissions setting.

Model Name and model type

Model Name must be a catalog id spelled exactly, without a provider prefix, and the model type must be LLM for a chat id; an embedding or rerank type sends a test of the wrong kind. Check the id without a key:

bash
curl https://api.uplinkswitch.com/v1/catalog

When a model that saved before begins failing, read its availability in that reply. The 2026-11-23 snapshot showed deepseek-v4.1-flash as ok and gpt-6.1-sol as ok; a degraded id calls for adding a sibling entry, not for rebuilding the provider.

Calls that fail after a clean save

A save proves one short test request, not every call an app will send. The usual later failure is a size setting: a model context size or a max tokens bound larger than the id allows. Copy both from the catalog entry instead of guessing, so gpt-6.1-sol gets 1.1M of context and at most 128K of output. Each model is its own entry under the one provider; reaching another id never takes a second provider.

Questions and answers

In the model provider settings, install the OpenAI-API-compatible provider and add a model from its card. Its API Base URL field takes the gateway root ending in /v1; a value with a route after it is the usual reason the save fails.

One provider, then one model entry per catalog id, each with the same base URL and key. Set the type to LLM for a chat id, and give every entry its own context size and max tokens from the catalog.

The figures the catalog lists for that id, its context_window and max_output_tokens, or lower. A number above what the model allows can still pass the save, because the test request is small, and then fail on a long real call.
Join on Telegram
Help