linshenkx/prompt-optimizer · error · Error
This model does not support text-to-image or image-to-image
Error message
This model does not support text-to-image or image-to-image generation
What it means
selectTestType in useImageModelManager derives which generation mode to test by checking the selected model's text2image/image2image capability flags. If neither capability is true, it throws because there is no valid image test to run for that model.
Source
Thrown at packages/ui/src/composables/model/useImageModelManager.ts:397
// 辅助函数:根据模型能力选择测试类型
const selectTestType = (model: ImageModel): 'text2image' | 'image2image' => {
const capabilities = model.capabilities || {}
const text2image = capabilities?.text2image
const image2image = capabilities?.image2image
if (text2image && !image2image) {
return 'text2image' // 只支持文生图
}
if (!text2image && image2image) {
return 'image2image' // 只支持图生图
}
if (text2image && image2image) {
return 'text2image' // 两种都支持,优先文生图
}
throw new Error('This model does not support text-to-image or image-to-image generation')
}
const testConnection = async () => {
if (!selectedProvider.value || !hasValidConnectionConfig(configForm.value.connectionConfig || {})) {
return
}
// 检查是否选择了模型
if (!configForm.value.modelId) {
toast.error(t('image.model.selectRequired'))
return
}
isTestingConnection.value = true
connectionStatus.value = { type: 'info', messageKey: 'image.connection.testing' }
try {
// 本地先做详细校验,给出缺失与类型错误提示View on GitHub (pinned to 3e677b1d9f)
Solutions
- Filter or flag models in the picker so only models with text2image or image2image capability can reach the test flow.
- Ensure capability detection (probe/adapter) runs and populates text2image/image2image before selectTestType is called.
- Catch the error and show a capability warning instead of crashing the dialog.
Example fix
// before
const testType = selectTestType(model)
// after
const caps = model.capabilities ?? {}
if (!caps.text2image && !caps.image2image) {
toast.warning('Selected model has no image generation capability')
return null
}
const testType = selectTestType(model) Defensive patterns
Strategy: validation
Validate before calling
const caps = model?.capabilities ?? {}
const canTestImage = Boolean(caps.text2image || caps.image2image)
if (!canTestImage) { /* skip test, warn user */ } Type guard
const supportsImageGeneration = (m: { capabilities?: { text2image?: boolean; image2image?: boolean } }): boolean =>
Boolean(m.capabilities?.text2image || m.capabilities?.image2image) Try / catch
try { const t = selectTestType(model) } catch (e) { if (e instanceof Error && /does not support/.test(e.message)) { warnNoImageCapability(); return } throw e } Prevention
- Run capability detection before offering the test action
- Only list image-capable models in the image manager
When it happens
Trigger: Calling testType/selectTestType for a model whose capabilities object has text2image=false (or missing) and image2image=false (or missing), e.g. an LLM-only or video-only model selected in the image model manager.
Common situations: User pastes a custom model ID that defaults to no image capabilities; provider returns a model listing where capability flags were not mapped; model metadata cached from an older version lacking the capability fields.
Related errors
- TEXT2IMAGE_INPUT_IMAGE_NOT_ALLOWED
- CONFIG_NOT_FOUND
- CONTEXT_ERROR_CODES.STORAGE_ERROR
- CONTEXT_ERROR_CODES.IMPORT_FORMAT_ERROR
- DATA_ERROR_CODES.ELECTRON_API_UNAVAILABLE
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/2edf9f07edfbbde0.
Report an issue: GitHub.