CherryHQ/cherry-studio · error · Error
ModelScope provider requires a non-empty `baseURL`.
Error message
ModelScope provider requires a non-empty `baseURL`.
What it means
Thrown by `createModelscopeProvider` when `settings.baseURL` is falsy. Unlike DashScope/DMXAPI, the image transport's `imageBaseURL` has a built-in default (`DEFAULT_MODELSCOPE_BASE_URL`), so this guard specifically protects the chat/embedding OpenAI-compatible endpoint which has no default. Chat and embedding calls need an explicit host.
Source
Thrown at src/main/ai/provider/custom/modelscope/modelscopeProvider.ts:51
* registry (`resolveImageTransport`) so the job handler can rebuild the same
* transport after a restart from the re-resolved provider settings.
*/
export function buildModelscopeTransport(settings: ModelscopeProviderSettings): ImageGenerationTransport {
return createModelscopeTransport({
apiKey: settings.apiKey ?? '',
baseURL: settings.imageBaseURL || DEFAULT_MODELSCOPE_BASE_URL
})
}
/**
* Unified ModelScope (魔搭) provider: OpenAI-compatible chat/embedding off
* `settings.baseURL`, plus an async submit/poll image transport off
* `settings.imageBaseURL` (defaults to `https://api-inference.modelscope.cn`).
*/
export function createModelscopeProvider(settings: ModelscopeProviderSettings = {}): ModelscopeProvider {
const { baseURL, fetch: customFetch } = settings
if (!baseURL) {
throw new Error('ModelScope provider requires a non-empty `baseURL`.')
}
const resolveApiKey = () =>
loadApiKey({ apiKey: settings.apiKey, environmentVariableName: 'MODELSCOPE_API_KEY', description: 'ModelScope' })
const authHeaders = () => ({
Authorization: `Bearer ${resolveApiKey()}`,
...settings.headers
})
const url = ({ path }: { path: string; modelId: string }) => `${withoutTrailingSlash(baseURL)}${path}`
const createChatModel = (modelId: string) =>
new OpenAICompatibleChatLanguageModel(modelId, {
provider: `${MODELSCOPE_PROVIDER_NAME}.chat`,
url,
headers: authHeaders,
fetch: customFetchView on GitHub (pinned to 726446b54c)
Solutions
- Set `baseURL` on the ModelScope provider settings to the OpenAI-compatible host, e.g. `https://api-inference.modelscope.cn/v1/`.
- Verify the provider config builder forwards the user-configured host.
- If only using image generation, prefer `buildModelscopeTransport` directly (it has a default base).
Example fix
// before
createModelscopeProvider({ apiKey: 'ms-...' })
// after
createModelscopeProvider({ apiKey: 'ms-...', baseURL: 'https://api-inference.modelscope.cn/v1/' }) Defensive patterns
Strategy: validation
Validate before calling
function assertModelscopeSettings(s: { baseURL?: string }) {
if (!s.baseURL) throw new Error('ModelScope baseURL required before creating provider')
}
assertModelscopeSettings(settings)
const provider = createModelscopeProvider(settings) Type guard
const hasModelscopeBaseURL = (s: { baseURL?: string }): s is { baseURL: string } =>
typeof s.baseURL === 'string' && s.baseURL.trim().length > 0 Prevention
- Make baseURL required in the ModelScope settings schema
- For image-only use, prefer buildModelscopeTransport (has a default base)
- Validate provider config before factory creation
When it happens
Trigger: Instantiating the ModelScope provider with no `baseURL` — `createModelscopeProvider({})`. The image transport alone would still work (defaults apply), but chat/embedding would have no target.
Common situations: ModelScope provider added in settings with only an image endpoint configured; the API host field left blank; a migration dropped `baseURL`.
Related errors
- DashScope provider requires a non-empty `baseURL`. An empty
- DMXAPI provider requires a non-empty `baseURL` to build the
- DMXAPI provider requires a non-empty `baseURL`. An empty val
- Private key must be a non-empty string
- Cherry Assistant package configuration is invalid: ${invalid
AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12).
Data as JSON: /api/errors/4d4ba8691d1449e7.
Report an issue: GitHub.