CherryHQ/cherry-studio · error · Error

DMXAPI provider requires a non-empty `baseURL` to build the

Error message

DMXAPI provider requires a non-empty `baseURL` to build the image transport.

What it means

Thrown by `buildDmxapiTransport` when neither `settings.endpointBaseURLs[OPENAI_CHAT_COMPLETIONS]` nor `settings.baseURL` is set. The image transport POSTs to host-root paths (`/v1/images/...`) and needs a host to anchor them. This builder is shared by the provider factory and the image-generation job's transport registry, so it can also fire on a restart resume.

Source

Thrown at src/main/ai/provider/custom/dmxapi/dmxapiProvider.ts:97

 * `createImageModelV3` below — the image-generation job's transport registry
 * (`resolveImageTransport`) uses this to decide whether DMXAPI generation goes
 * through the job. Native families (gpt-image / dall-e / imagen / gemini-image)
 * and the `openai-flat` compat fallback keep the in-SDK path.
 */
export function dmxapiUsesCustomTransport(modelId: string): boolean {
  return resolveNativeImageFamily(modelId) === 'openai-compat-image' && resolveDmxapiFamily(modelId) !== 'openai-flat'
}

/**
 * Build the DMXAPI submit/poll image transport from provider settings. Shared
 * by the provider factory and the image-generation job's transport registry so
 * the job handler can rebuild the same transport after a restart from the
 * re-resolved provider settings.
 */
export function buildDmxapiTransport(settings: DmxapiProviderSettings): ImageGenerationTransport {
  const chatBaseURL = settings.endpointBaseURLs?.[ENDPOINT_TYPE.OPENAI_CHAT_COMPLETIONS] ?? settings.baseURL
  if (!chatBaseURL) {
    throw new Error('DMXAPI provider requires a non-empty `baseURL` to build the image transport.')
  }
  return createDmxapiTransport({
    apiKey: settings.apiKey ?? '',
    // The transport POSTs to host-root paths (`/v1/images/...`), so strip the
    // OpenAI-compat version suffix from the chat baseURL to avoid a double `/v1`.
    baseURL: withoutTrailingApiVersion(chatBaseURL)
  })
}

export function createDmxapiProvider(settings: DmxapiProviderSettings = {}): DmxapiProvider {
  const { baseURL, fetch: customFetch } = settings
  if (!baseURL) {
    throw new Error(
      'DMXAPI 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 = () =>

View on GitHub (pinned to 726446b54c)

Solutions

  1. Ensure `baseURL` (or `endpointBaseURLs[OPENAI_CHAT_COMPLETIONS]`) is set on the DMXAPI provider settings.
  2. If hitting this on restart resume, verify the job re-resolves the full provider settings including the base URL.
  3. Guard the settings object before calling `buildDmxapiTransport`.

Example fix

// before
buildDmxapiTransport({ apiKey: 'sk-...' })
// after
buildDmxapiTransport({ apiKey: 'sk-...', baseURL: 'https://www.dmxapi.cn/v1' })
Defensive patterns

Strategy: validation

Validate before calling

const chatBaseURL = settings.endpointBaseURLs?.[ENDPOINT_TYPE.OPENAI_CHAT_COMPLETIONS] ?? settings.baseURL
if (!chatBaseURL) {
  throw new Error('Cannot build DMXAPI image transport — set baseURL or endpointBaseURLs[OPENAI_CHAT_COMPLETIONS]')
}
buildDmxapiTransport(settings)

Type guard

const hasDmxapiChatBase = (s: DmxapiProviderSettings): boolean =>
  !!(s.endpointBaseURLs?.[ENDPOINT_TYPE.OPENAI_CHAT_COMPLETIONS] ?? s.baseURL)

Prevention

When it happens

Trigger: Building the DMXAPI image transport from settings that carry no chat base URL — either the provider was created with neither field, or the job's restart-resume path re-resolved settings that lost the base URL.

Common situations: Provider record persisted without a base URL after a config edit; the job handler rebuilt the transport from a stale/partial settings snapshot; `endpointBaseURLs` was set for other endpoint types but not chat.

Related errors


AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12). Data as JSON: /api/errors/9fb5346ff89cbe52. Report an issue: GitHub.