{"record":{"id":"be871133f0768e14","repo":"siyuan-note/siyuan","slug":"image-model-is-not-configured","errorCode":null,"errorMessage":"image model is not configured","messagePattern":"image model is not configured","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/assets.go","lineNumber":589,"sourceCode":"\treturn GenerateDocumentImageResult{\n\t\tArtifact: ImageArtifactRef{\n\t\t\tKind: \"image\", Path: assetPath, MIMEType: generated.MIMEType, DocumentID: bt.RootID,\n\t\t},\n\t\tRevisedPrompt: generated.RevisedPrompt,\n\t}, nil\n}\n\nfunc resolveMultimodalDocument(documentID string) (*treenode.BlockTree, error) {\n\tbt := treenode.GetBlockTree(strings.TrimSpace(documentID))\n\tif bt == nil {\n\t\treturn nil, errors.New(\"document not found: \" + documentID)\n\t}\n\treturn bt, nil\n}\n\nfunc validateImageModel(provider *conf.Provider, imageModel *conf.Model) error {\n\tif provider == nil || imageModel == nil {\n\t\treturn errors.New(\"image model is not configured\")\n\t}\n\tif provider.Protocol != \"\" && provider.Protocol != util.OpenAIProtocolChatCompletions &&\n\t\tprovider.Protocol != util.OpenAIProtocolResponses {\n\t\treturn fmt.Errorf(\"unsupported multimodal provider protocol: %s\", provider.Protocol)\n\t}\n\treturn nil\n}\n\nfunc documentReferencesImage(rootID, assetPath string) bool {\n\tpaths, err := DocImageAssets(rootID)\n\tif err != nil {\n\t\treturn false\n\t}\n\twanted := AssetPathWithoutQuery(assetPath)\n\tfor _, current := range paths {\n\t\tif AssetPathWithoutQuery(current) == wanted {\n\t\t\treturn true\n\t\t}","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/assets.go#L571-L607","documentation":"validateImageModel checks that both the resolved AI provider (conf.Provider) and the image-generation model (conf.Model) are non-nil. If either is missing — meaning no image-generation provider/model is configured in Settings - AI — it returns \"image model is not configured\". It then also validates the provider protocol.","triggerScenarios":"Conf.AI.GetImageGenerationModel() returns nil provider or nil model because the user never selected an image generation model, the configured provider was deleted, or the model list failed to load; calling GenerateImage on a fresh installation with default (empty) AI settings.","commonSituations":"Fresh install with no AI configuration; user configured a chat model but not an image model; config synced from a machine where the image model pointed to a provider that no longer exists; API key removed leaving the provider entry incomplete.","solutions":["Open Settings - AI - Image generation and select a provider and model, then save","Verify Conf.AI.ImageGeneration has a valid provider with API key and an image-capable model name","In code, check Conf.AI.GetImageGenerationModel() for nil before calling GenerateImage to give a friendlier message","Re-add the provider entry if the referenced provider was removed from the provider list"],"exampleFix":"// before\nprovider, m := conf.Conf.AI.GetImageGenerationModel() // nil, nil\nresult, err := model.GenerateImage(ctx, req)\n// after\nprovider, m := conf.Conf.AI.GetImageGenerationModel()\nif provider == nil || m == nil { return errors.New(\"configure an image model in Settings - AI first\") }\nresult, err = model.GenerateImage(ctx, req)","handlingStrategy":"validation","validationCode":"provider, m := conf.Conf.AI.GetImageGenerationModel()\nif provider == nil || m == nil {\n    return errors.New(\"select an image generation provider and model in Settings - AI first\")\n}","typeGuard":"func imageModelConfigured() bool {\n    p, m := conf.Conf.AI.GetImageGenerationModel()\n    return p != nil && m != nil && p.APIKey != \"\"\n}","tryCatchPattern":"res, err := model.GenerateImage(ctx, req)\nif err != nil && err.Error() == \"image model is not configured\" {\n    // direct the user to Settings - AI - Image generation instead of retrying\n}","preventionTips":["Configure an image generation model before calling any GenerateImage path","After provider changes, confirm the image model still resolves to an existing provider","Add a startup check that logs when no image model is configured"],"tags":["configuration","ai","image-generation"],"backgroundTag":"missing-required-config","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}