{"record":{"id":"5b99f89980c6c754","repo":"vercel/ai","slug":"no-such-imagemodel-modelid-5b99f8","errorCode":null,"errorMessage":"No such imageModel: ${modelId}","messagePattern":"No such imageModel: (.+?)","errorType":"exception","errorClass":"NoSuchModelError","httpStatus":null,"severity":"error","filePath":"packages/zai/src/zai-provider.ts","lineNumber":97,"sourceCode":"    new ZaiChatLanguageModel(modelId, {\n      provider: 'zai.chat',\n      baseURL,\n      headers: getHeaders,\n      fetch: options.fetch,\n    });\n\n  const provider = (modelId: ZaiChatModelId) => createLanguageModel(modelId);\n\n  provider.specificationVersion = 'v4' as const;\n  provider.languageModel = createLanguageModel;\n  provider.chat = createLanguageModel;\n\n  provider.embeddingModel = (modelId: string) => {\n    throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n  };\n  provider.textEmbeddingModel = provider.embeddingModel;\n  provider.imageModel = (modelId: string) => {\n    throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n  };\n\n  return provider;\n}\n\nexport const zai = createZai();\n","sourceCodeStart":79,"sourceCodeEnd":104,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/zai/src/zai-provider.ts#L79-L104","documentation":"The z.ai provider does not implement image models; its imageModel factory unconditionally throws NoSuchModelError with modelType 'imageModel'. Only language models are supported by this provider, so any imageModel lookup fails immediately without a network call.","triggerScenarios":"zai.imageModel('cogview-4') called directly; generateImage() with model: zai('some-model'); provider factories that resolve image models by provider string.","commonSituations":"Multi-provider image pipelines routing to zai by mistake; assuming z.ai image APIs are wrapped by the SDK; configuration tables listing providers without per-capability support flags.","solutions":["Use an image-capable provider, e.g. openai.image('gpt-image-1') or another provider implementing image models.","Restrict zai usage to text/chat workloads in your model registry.","Check @ai-sdk/zai release notes for future image model support."],"exampleFix":"// before\nconst { image } = await generateImage({ model: zai.imageModel('cogview-4'), prompt });\n\n// after\nimport { openai } from '@ai-sdk/openai';\nconst { image } = await generateImage({ model: openai.image('gpt-image-1'), prompt });","handlingStrategy":"fallback","validationCode":"const ZAI_SUPPORTS_IMAGES = false;\nfunction getImageModel(preferred: 'zai' | 'openai') {\n  if (preferred === 'zai' && !ZAI_SUPPORTS_IMAGES) {\n    return openai.image('gpt-image-1');\n  }\n  // ...\n}","typeGuard":"function supportsImages(provider: any): boolean {\n  return typeof provider?.imageModel === 'function' &&\n    !/NoSuchModelError/.test(provider.imageModel.toString());\n}","tryCatchPattern":"try {\n  return await generateImage({ model: zai.imageModel(id), prompt });\n} catch (e) {\n  if (NoSuchModelError.isInstance(e) && e.modelType === 'imageModel') {\n    return await generateImage({ model: openai.image('gpt-image-1'), prompt });\n  }\n  throw e;\n}","preventionTips":["Check the provider README for supported capabilities (language/image/embedding) before wiring generateImage.","Centralize image model selection so zai cannot be chosen for image tasks.","Add CI tests asserting image routes resolve to image-capable providers."],"tags":["zai","image-generation","no-such-model","provider-capability"],"backgroundTag":"model-not-supported-by-provider","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}