{"record":{"id":"73336508d00b310d","repo":"jeecgboot/JeecgBoot","slug":"yml","errorCode":null,"errorMessage":"当前系统未配置默认图像模型，请前往yml中配置默认模型","messagePattern":"当前系统未配置默认图像模型，请前往yml中配置默认模型","errorType":"exception","errorClass":"JeecgBootBizTipException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/handler/AIChatHandler.java","lineNumber":537,"sourceCode":"        return this.imageGenerate(airagModel, messages, params);\n    }\n\n    /**\n     * 文本生成图片\n     *\n     * @param airagModel\n     * @param messages\n     * @param params\n     * @return\n     */\n    public List<Map<String, Object>> imageGenerate(AiragModel airagModel, String messages, AIChatParams params) {\n        if(airagModel == null || (airagModel.getActivateFlag()!=null && airagModel.getActivateFlag() == 0)){\n            if (airagModel != null && oConvertUtils.isNotEmpty(airagModel.getId())) {\n                log.warn(\"模型未激活,采用默认文生图模型\");\n            }\n            //判断是否配置了默认模型\n            if(aiChatConfig == null || oConvertUtils.isEmpty(aiChatConfig.getAiModelDraw().getApiKey())){\n                throw new JeecgBootBizTipException(\"当前系统未配置默认图像模型，请前往yml中配置默认模型\");\n            }\n            airagModel = this.getDefaultDrawModel(aiChatConfig.getAiModelDraw());\n        }\n        params = mergeParams(airagModel, params);\n        try {\n            return llmHandler.imageGenerate(messages, params);\n        } catch (Exception e) {\n            throw translateLlmException(e, \"调用绘画AI接口失败，详情请查看后台日志。\");\n        }\n    }\n\n\n    /**\n     * 图生图\n     * @param modelId\n     * @param messages\n     * @param params\n     * @return","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/handler/AIChatHandler.java#L519-L555","documentation":"This error is thrown by AIChatHandler.imageGenerate() (text-to-image) when the provided airagModel is null or inactive (activateFlag == 0) and no default image generation model is configured. The method checks if aiChatConfig.getAiModelDraw().getApiKey() is empty, and if so, rejects the request. This indicates the system's fallback image model configuration is incomplete.","triggerScenarios":"A text-to-image request is made with either no modelId, a null model, or a model with activateFlag=0. The code falls back to the default draw model configuration (aiChatConfig.getAiModelDraw()), but finds the API key is empty. This path is hit when the primary model is unavailable and the fallback is not configured.","commonSituations":"Fresh installation where AI image generation has never been configured. The AI model was deactivated in admin settings but no default was set in yml. The aiModelDraw configuration section is missing from application.yml. The API key was cleared during config migration.","solutions":["Configure the default image generation model in application.yml under the AI chat config section: set aiModelDraw with provider, apiKey, model name, and endpoint.","Alternatively, activate an existing image model in the admin UI (set activateFlag to 1) so the fallback path is not needed.","Verify that aiChatConfig is properly injected (not null) and the getAiModelDraw() returns a non-null object with a non-empty apiKey.","Check the complete AI configuration block in application-dev.yml / application-prod.yml for the aiModelDraw section."],"exampleFix":"# before (application.yml) — no default image model\njeecg:\n  aiChat:\n    aiModelDraw:\n      apiKey:  # empty\n\n# after\njeecg:\n  aiChat:\n    aiModelDraw:\n      provider: openai\n      apiKey: sk-your-api-key\n      modelName: dall-e-3\n      apiUrl: https://api.openai.com/v1/images/generations","handlingStrategy":"validation","validationCode":"// Before calling imageGenerate, verify model or default config\nif ((airagModel == null || airagModel.getActivateFlag() == null || airagModel.getActivateFlag() == 0)\n    && (aiChatConfig == null || aiChatConfig.getAiModelDraw() == null\n        || aiChatConfig.getAiModelDraw().getApiKey() == null\n        || aiChatConfig.getAiModelDraw().getApiKey().isEmpty())) {\n    throw new IllegalStateException(\"No image model available. Activate a model or configure aiModelDraw in yml.\");\n}","typeGuard":"public static boolean hasImageGenCapability(AiragModel model, AiChatConfig config) {\n    if (model != null && model.getActivateFlag() != null && model.getActivateFlag() == 1) return true;\n    return config != null\n        && config.getAiModelDraw() != null\n        && config.getAiModelDraw().getApiKey() != null\n        && !config.getAiModelDraw().getApiKey().isEmpty();\n}","tryCatchPattern":"try {\n    List<Map<String, Object>> images = aiChatHandler.imageGenerate(airagModel, messages, params);\n    return images;\n} catch (JeecgBootBizTipException e) {\n    if (e.getMessage().contains(\"未配置默认图像模型\")) {\n        // Return user-friendly guidance\n        return Collections.emptyList(); // or show configuration prompt\n    }\n    throw e;\n}","preventionTips":["Configure a default image generation model in application.yml at deployment time","Add a startup health check that verifies AI model configurations","Activate at least one image model in the admin UI as a fallback","Display configuration status in the admin dashboard"],"tags":["airag","ai","image-generation","configuration"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}