CherryHQ/cherry-studio · error · Error
DashScope provider requires a non-empty `baseURL`. An empty
Error message
DashScope provider requires a non-empty `baseURL`. An empty value would resolve fetch paths against the renderer process origin (app://, file://) and surface as opaque "Failed to fetch" errors.
What it means
Thrown by the DashScope provider factory `createDashScopeProvider` when `settings.baseURL` is falsy. The guard fires eagerly because, inside Electron's main process, an empty base makes relative fetch paths resolve against the renderer origin (`app://`, `file://`), which surfaces as opaque "Failed to fetch" errors that hide the real cause. Failing fast with a clear message is preferred over a cryptic network failure later.
Source
Thrown at src/main/ai/provider/custom/dashscope/dashscopeProvider.ts:70
export function buildDashScopeTransport(settings: DashScopeProviderSettings): ImageGenerationTransport {
return createDashScopeTransport({
apiKey: settings.apiKey ?? '',
imageBaseURL: settings.imageBaseURL || DEFAULT_DASHSCOPE_IMAGE_BASE_URL
})
}
/**
* Unified DashScope (Bailian) provider — chat, embedding, and image off one
* `ProviderV3`. Chat / embedding go through the OpenAI-compatible SDK aimed at
* `baseURL` (DashScope exposes `/compatible-mode/v1/`); image goes through the
* native DashScope `/api/v1/services/aigc/*` endpoints via
* `createImageGenerationModel + createDashScopeTransport` aimed at
* `imageBaseURL`.
*/
export function createDashScopeProvider(settings: DashScopeProviderSettings = {}): DashScopeProvider {
const { baseURL, fetch: customFetch } = settings
if (!baseURL) {
throw new Error(
'DashScope provider requires a non-empty `baseURL`. An empty value would resolve fetch paths against the renderer process origin (app://, file://) and surface as opaque "Failed to fetch" errors.'
)
}
const resolveApiKey = () =>
loadApiKey({ apiKey: settings.apiKey, environmentVariableName: 'DASHSCOPE_API_KEY', description: 'DashScope' })
const authHeaders = () => ({
Authorization: `Bearer ${resolveApiKey()}`,
...settings.headers
})
const url = ({ path }: { path: string; modelId: string }) => `${withoutTrailingSlash(baseURL)}${path}`
// DashScope chat uses /compatible-mode/v1; rerank uses /compatible-api/v1 on the same user-configured host.
const rerankBaseURL = getDashScopeRerankBaseURL(baseURL)
const rerankUrl = ({ path }: { path: string; modelId: string }) =>
`${rerankBaseURL}${path === '/rerank' ? '/reranks' : path}`View on GitHub (pinned to 726446b54c)
Solutions
- Set `baseURL` in the DashScope provider settings to the OpenAI-compatible chat host, e.g. `https://dashscope.aliyuncs.com/compatible-mode/v1/`.
- Verify the provider config builder forwards the user-configured host into `baseURL` (not only `imageBaseURL`).
- If only image generation is intended, confirm `buildDashScopeTransport` is the right entry point — but note the unified factory still requires `baseURL` for chat/embedding model wiring.
Example fix
// before
createDashScopeProvider({ apiKey: 'sk-...' })
// after
createDashScopeProvider({ apiKey: 'sk-...', baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1/' }) Defensive patterns
Strategy: validation
Validate before calling
function assertDashScopeSettings(s: { baseURL?: string }) {
if (!s.baseURL) throw new Error('DashScope baseURL required before creating provider')
}
assertDashScopeSettings(settings)
const provider = createDashScopeProvider(settings) Type guard
const hasBaseURL = (s: { baseURL?: string }): s is { baseURL: string } =>
typeof s.baseURL === 'string' && s.baseURL.trim().length > 0 Prevention
- Make baseURL required in the provider settings schema (non-empty string)
- Validate provider config before passing to the factory
- Cover the factory with a unit test that asserts it throws on missing baseURL
When it happens
Trigger: Instantiating the provider via `createDashScopeProvider({})` or `createDashScopeProvider({ baseURL: '' })` — i.e. the provider config builder resolved no API host. Chat and embedding endpoints both need this base; `imageBaseURL` alone is not enough.
Common situations: The DashScope provider was added in settings but the API host field was left blank; a settings migration dropped the `baseURL` field; the user only filled the image endpoint, forgetting chat/embedding share the chat base.
Related errors
- DMXAPI provider requires a non-empty `baseURL`. An empty val
- DMXAPI provider requires a non-empty `baseURL` to build the
- ModelScope provider requires a non-empty `baseURL`.
- 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/fb8f175dae1bea09.
Report an issue: GitHub.