vercel/ai · error · NoSuchModelError
imageModel
Error message
imageModel
What it means
The DeepSeek provider does not support image models; its imageModel factory unconditionally throws NoSuchModelError with modelType 'imageModel'. DeepSeek offers no image generation API, so the stub enforces that contract loudly.
Source
Thrown at packages/deepseek/src/deepseek-provider.ts:120
baseURL,
headers: getHeaders,
fetch: options.fetch,
});
const provider = (modelId: DeepSeekChatModelId) =>
createLanguageModel(modelId);
provider.specificationVersion = 'v4' as const;
provider.languageModel = createLanguageModel;
provider.chat = createLanguageModel;
provider.files = createFiles;
provider.embeddingModel = (modelId: string) => {
throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });
};
provider.textEmbeddingModel = provider.embeddingModel;
provider.imageModel = (modelId: string) => {
throw new NoSuchModelError({ modelId, modelType: 'imageModel' });
};
return provider;
}
export const deepSeek = createDeepSeek();
View on GitHub (pinned to 69428b1f8b)
Solutions
- Use an image-capable provider for generateImage (e.g. @ai-sdk/openai with dall-e/gpt-image, @ai-sdk/google, @ai-sdk/amazon-bedrock).
- Configure a dedicated image provider separate from the chat provider.
- Guard image-generation code paths to check provider support before resolving the model.
Example fix
// before
await generateImage({ model: deepseek.imageModel('img'), prompt });
// after
import { createOpenAI } from '@ai-sdk/openai';
const openai = createOpenAI({ apiKey: openaiKey });
await generateImage({ model: openai.image('gpt-image-1'), prompt }); Defensive patterns
Strategy: validation
Validate before calling
function supportsImages(provider: unknown): boolean {
return typeof (provider as any)?.imageModel === 'function' &&
!/deepseek/i.test((provider as any)?.provider ?? '');
} Type guard
function isImageCapable(p: any): p is { imageModel: (id: string) => unknown } {
return typeof p?.imageModel === 'function';
} Try / catch
try {
await generateImage({ model: provider.imageModel(id), prompt });
} catch (e) {
if (NoSuchModelError.isInstance(e) && e.modelType === 'imageModel') {
throw new Error('DeepSeek cannot generate images; use an image provider.');
}
throw e;
} Prevention
- Route image generation only to providers documented as image-capable.
- Maintain a capability map in config rather than one provider for all tasks.
- Add unit tests asserting which model types each configured provider supports.
When it happens
Trigger: Calling generateImage() with a DeepSeek model, or calling deepseek.imageModel('some-id') directly.
Common situations: Generic multi-provider pipelines that route image generation to whichever provider is configured, or developers exploring the provider API assuming image support exists.
Related errors
- AI_NoSuchModelError
- ElevenLabs does not provide image models
- No such imageModel: ${modelId}
- imageModel
- imageModel
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/c197a5edeb4f4f3b.
Report an issue: GitHub.