siyuan-note/siyuan · error
AI configuration is unavailable
Error message
AI configuration is unavailable
What it means
Returned by GenerateImage when the global Conf is nil or Conf.AI is nil — i.e. the kernel configuration has not been loaded (or the AI subsystem was never initialized). It fires before any model lookup, so it indicates the feature is entirely unavailable in this build/session, not a misconfigured model.
Source
Thrown at kernel/model/assets.go:415
}
prepared, err := util.PrepareModelImage(
data, documentImageMaxBytes, documentImageMaxPixels, documentImageMaxEdge,
)
if err != nil {
return PreparedDocumentImage{}, err
}
return PreparedDocumentImage{
Artifact: ImageArtifactRef{Kind: "image", Path: assetPath, DocumentID: bt.RootID},
Data: prepared.Data,
MIMEType: prepared.MIMEType,
Prepared: prepared,
}, nil
}
// GenerateImage 使用全局图片生成配置创建图片字节,可供文档资源、编辑器和其他图片入口复用。
func GenerateImage(ctx context.Context, request GenerateImageRequest) (GenerateImageResult, error) {
if Conf == nil || Conf.AI == nil {
return GenerateImageResult{}, errors.New("AI configuration is unavailable")
}
provider, generationModel := Conf.AI.GetImageGenerationModel()
if err := validateImageModel(provider, generationModel); err != nil {
return GenerateImageResult{}, err
}
prompt := strings.TrimSpace(request.Prompt)
if prompt == "" {
return GenerateImageResult{}, errors.New("prompt is required for image generation")
}
size := multimodalValueOrDefault(request.Size, Conf.AI.ImageGeneration.Size)
quality := multimodalValueOrDefault(request.Quality, Conf.AI.ImageGeneration.Quality)
outputFormat := strings.ToLower(multimodalValueOrDefault(request.OutputFormat, Conf.AI.ImageGeneration.OutputFormat))
if outputFormat != "png" && outputFormat != "jpeg" && outputFormat != "webp" {
return GenerateImageResult{}, errors.New("unsupported image output format")
}
generated, err := util.NewOpenAIImageAdapter(
provider.APIKey, provider.BaseURL, generationModel.Name, Conf.AI.ImageGeneration.RequestTimeout,
).Generate(ctx, util.GenerateImageRequest{View on GitHub (pinned to 251596fc0d)
Solutions
- Ensure the kernel is fully booted (util.Boot completed) and conf.json is loaded before invoking GenerateImage.
- If the AI section was removed, restore it from a backup or re-create it through the settings UI.
- Guard callers: check model.Conf != nil && model.Conf.AI != nil before offering image-generation actions in the UI.
Example fix
// before
res, err := model.GenerateImage(ctx, req)
// after — guard the feature gate
if model.Conf == nil || model.Conf.AI == nil {
return errors.New("image generation unavailable: AI not configured")
}
res, err := model.GenerateImage(ctx, req) Defensive patterns
Strategy: validation
Validate before calling
if model.Conf == nil || model.Conf.AI == nil {
return errors.New("AI subsystem not initialized")
} Prevention
- Only expose image-generation UI actions after the kernel boot completes and Conf.AI loads.
- In tests, bootstrap a minimal Conf.AI before exercising GenerateImage.
- Treat a nil Conf.AI as a feature-unavailable signal and disable the entry point.
When it happens
Trigger: Calling GenerateImage during kernel boot before Conf is populated; calling it in a context (mobile binding, headless tool) where the AI config was never read; a corrupted conf.json that deserialized to a nil AI block.
Common situations: An integration test invokes GenerateImage without booting the kernel; a plugin runs against a kernel that hasn't finished Boot(); the user deleted or zeroed out the AI section of their config.
Related errors
- no AI provider configured
- no AI editing config
- image model is not configured
- unsupported multimodal provider protocol: %s
- unsupported server type: %s
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/d740ef11ca2f42d2.
Report an issue: GitHub.