{"record":{"id":"3f3c76a48714a357","repo":"CherryHQ/cherry-studio","slug":"imagemodel","errorCode":null,"errorMessage":"imageModel","messagePattern":"imageModel","errorType":"exception","errorClass":"NoSuchModelError","httpStatus":null,"severity":"error","filePath":"src/main/ai/provider/custom/moonshotProvider.ts","lineNumber":156,"sourceCode":"      includeUsage: settings.includeUsage\n    })\n\n  const createEmbeddingModel = (modelId: string) =>\n    new OpenAICompatibleEmbeddingModel(modelId, {\n      provider: `${MOONSHOT_PROVIDER_NAME}.embedding`,\n      url,\n      headers,\n      fetch: customFetch\n    })\n\n  const provider = (modelId: string) => createChatModel(modelId)\n  provider.specificationVersion = 'v3' as const\n  provider.languageModel = createChatModel\n  provider.chatModel = createChatModel\n  provider.embeddingModel = createEmbeddingModel\n  provider.textEmbeddingModel = createEmbeddingModel\n  provider.imageModel = (modelId: string) => {\n    throw new NoSuchModelError({ modelId, modelType: 'imageModel' })\n  }\n\n  return provider as MoonshotProvider\n}\n","sourceCodeStart":138,"sourceCodeEnd":161,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/provider/custom/moonshotProvider.ts#L138-L161","documentation":"NoSuchModelError is the AI SDK's standard error for 'this provider does not serve this model type'. createMoonshotProvider explicitly throws it from provider.imageModel() because Moonshot only exposes chat and embedding models — there is no image generation backend. The error carries modelId and modelType='imageModel' for the SDK's error-handling pipeline.","triggerScenarios":"Anything calls provider.imageModel(someId) on a Moonshot provider instance — typically the unified provider facade when the dispatcher routes an image-generation request to the moonshot provider by mistake, or a model record is mis-typed as an image model in configuration.","commonSituations":"A model registered under the moonshot provider with the wrong capability/type (marked image-capable), or generic code that probes provider.imageModel for every provider without a capability check.","solutions":["Do not route image-generation requests to the Moonshot provider — it has no image backend. Use a provider that exposes createImageGenerationModel/createImageModel.","Audit the model registry: ensure models under the moonshot provider are typed as chat/embedding, not image.","If writing generic dispatcher code, guard with a capability check (hasImageTransport / provider capability flags) before calling provider.imageModel().","Catch NoSuchModelError at the call site and surface a user-facing 'model type not supported by this provider' message."],"exampleFix":"// before\nconst img = provider.imageModel(modelId) // throws on moonshot\n// after — capability gate before resolution\nif (!providerCapabilities(providerId).image) {\n  throw new Error(`Provider '${providerId}' does not support image generation`)\n}\nconst img = provider.imageModel(modelId)","handlingStrategy":"type-guard","validationCode":"// Capability check before resolving an image model\nif (!providerCapabilities(providerId).image) {\n  throw new Error(`Provider '${providerId}' does not support image generation`)\n}","typeGuard":"import { NoSuchModelError } from '@ai-sdk/provider'\nexport function isNoSuchImageModelError(e: unknown): boolean {\n  return e instanceof NoSuchModelError && (e as any).modelType === 'imageModel'\n}","tryCatchPattern":"try {\n  provider.imageModel(modelId)\n} catch (e) {\n  if (e instanceof NoSuchModelError) {\n    // route to a different provider or surface to user\n  }\n  throw e\n}","preventionTips":["Gate image-model resolution on a provider capability flag.","Never mark a Moonshot model as image-capable in the registry.","Catch NoSuchModelError at dispatch and route to a supported provider."],"tags":["model-not-found","moonshot","ai-sdk","configuration","image-generation"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}