{"record":{"id":"41ed4d8dd033486d","repo":"vercel/ai","slug":"imagemodel","errorCode":null,"errorMessage":"imageModel","messagePattern":"imageModel","errorType":"exception","errorClass":"NoSuchModelError","httpStatus":null,"severity":"error","filePath":"packages/anthropic/src/anthropic-provider.ts","lineNumber":199,"sourceCode":"      throw new Error(\n        'The Anthropic model function cannot be called with the new keyword.',\n      );\n    }\n\n    return createChatModel(modelId);\n  };\n\n  provider.specificationVersion = 'v4' as const;\n  provider.languageModel = createChatModel;\n  provider.chat = createChatModel;\n  provider.messages = createChatModel;\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  provider.files = () =>\n    new AnthropicFiles({\n      provider: providerName,\n      baseURL,\n      headers: getHeaders,\n      fetch: options.fetch,\n    });\n\n  provider.skills = createSkills;\n\n  provider.tools = anthropicTools;\n\n  return provider;\n}\n\n/**","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/anthropic/src/anthropic-provider.ts#L181-L217","documentation":"The Anthropic provider's `imageModel` factory is a stub that throws NoSuchModelError with modelType 'imageModel' for any modelId. Anthropic does not expose an image-generation capability through this provider, so every call fails.","triggerScenarios":"Calling `anthropic.imageModel('some-id')` or passing it to `generateImage({ model: anthropic.imageModel(...) })`.","commonSituations":"Trying to generate images with Claude; generic image pipelines configured with the wrong provider; assuming multimodal input support implies image generation support.","solutions":["Use an image-capable provider, e.g. `createOpenAI().image('dall-e-3')`, `@ai-sdk/google` (Imagen), or `@ai-sdk/amazon-bedrock`.","Keep Anthropic for text/chat and route image generation to a dedicated provider instance."],"exampleFix":"// before\nconst model = anthropic.imageModel('claude-image');\n// after\nimport { createOpenAI } from '@ai-sdk/openai';\nconst model = createOpenAI().image('dall-e-3');","handlingStrategy":"fallback","validationCode":"if (providerId === 'anthropic') {\n  throw new Error('Image generation requires an image-capable provider');\n}\nconst imageModel = imageProviders[providerId].imageModel(modelId);","typeGuard":"function supportsImages(p: any): boolean {\n  try {\n    p.imageModel('probe');\n    return true;\n  } catch (e) {\n    return !(NoSuchModelError.isInstance(e) && e.modelType === 'imageModel');\n  }\n}","tryCatchPattern":"try {\n  return await generateImage({ model: anthropic.imageModel(id), prompt });\n} catch (error) {\n  if (NoSuchModelError.isInstance(error) && error.modelType === 'imageModel') {\n    return generateImage({ model: openai.image('dall-e-3'), prompt });\n  }\n  throw error;\n}","preventionTips":["Route image generation only to providers documented as image-capable.","Centralize model resolution so unsupported provider/model-type pairs are rejected early.","Document that Anthropic is text/chat-only in team provider guidelines."],"tags":["unsupported-model-type","image-generation","provider-capability"],"backgroundTag":"model-type-not-supported","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}