vercel/ai · error · NoSuchModelError
imageModel
Error message
imageModel
What it means
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.
Source
Thrown at packages/anthropic/src/anthropic-provider.ts:199
throw new Error(
'The Anthropic model function cannot be called with the new keyword.',
);
}
return createChatModel(modelId);
};
provider.specificationVersion = 'v4' as const;
provider.languageModel = createChatModel;
provider.chat = createChatModel;
provider.messages = createChatModel;
provider.embeddingModel = (modelId: string) => {
throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });
};
provider.textEmbeddingModel = provider.embeddingModel;
provider.imageModel = (modelId: string) => {
throw new NoSuchModelError({ modelId, modelType: 'imageModel' });
};
provider.files = () =>
new AnthropicFiles({
provider: providerName,
baseURL,
headers: getHeaders,
fetch: options.fetch,
});
provider.skills = createSkills;
provider.tools = anthropicTools;
return provider;
}
/**View on GitHub (pinned to 69428b1f8b)
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.
Example fix
// before
const model = anthropic.imageModel('claude-image');
// after
import { createOpenAI } from '@ai-sdk/openai';
const model = createOpenAI().image('dall-e-3'); Defensive patterns
Strategy: fallback
Validate before calling
if (providerId === 'anthropic') {
throw new Error('Image generation requires an image-capable provider');
}
const imageModel = imageProviders[providerId].imageModel(modelId); Type guard
function supportsImages(p: any): boolean {
try {
p.imageModel('probe');
return true;
} catch (e) {
return !(NoSuchModelError.isInstance(e) && e.modelType === 'imageModel');
}
} Try / catch
try {
return await generateImage({ model: anthropic.imageModel(id), prompt });
} catch (error) {
if (NoSuchModelError.isInstance(error) && error.modelType === 'imageModel') {
return generateImage({ model: openai.image('dall-e-3'), prompt });
}
throw error;
} Prevention
- 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.
When it happens
Trigger: Calling `anthropic.imageModel('some-id')` or passing it to `generateImage({ model: anthropic.imageModel(...) })`.
Common situations: Trying to generate images with Claude; generic image pipelines configured with the wrong provider; assuming multimodal input support implies image generation support.
Related errors
- imageModel
- AI_NoSuchModelError
- embeddingModel
- AssemblyAI does not provide language models
- embeddingModel
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/41ed4d8dd033486d.
Report an issue: GitHub.