vercel/ai · error · NoSuchModelError

imageModel

Error message

imageModel

What it means

The MiniMax provider does not implement image models: minimax.imageModel(modelId) unconditionally throws NoSuchModelError with modelType 'imageModel'. Only language/chat and video model factories are provided.

Source

Thrown at packages/minimax/src/minimax-provider.ts:150

      baseURL: videoBaseURL,
      headers: getVideoHeaders,
      fetch: options.fetch,
    });

  const provider = (modelId: MiniMaxChatModelId) => createChatModel(modelId);

  provider.specificationVersion = 'v4' as const;
  provider.languageModel = createChatModel;
  provider.chat = createChatModel;
  provider.video = createVideoModel;
  provider.videoModel = createVideoModel;

  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 minimax = createMiniMax();

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Use an image-capable provider, e.g. openai.imageModel('dall-e-3') or another provider implementing imageModel, with generateImage.
  2. Restrict minimax usage to chat (minimax.chat) and video (minimax.videoModel) models.
  3. Add a runtime capability check (typeof provider.imageModel === 'function' won't help here — check provider docs/feature matrix) before dispatching image generation.

Example fix

// before
const { image } = await generateImage({
  model: minimax.imageModel('image-01'),
  prompt,
});
// after
const { image } = await generateImage({
  model: openai.imageModel('dall-e-3'),
  prompt,
});
Defensive patterns

Strategy: validation

Validate before calling

if (needsImageGeneration && providerId === 'minimax') {
  throw new Error('minimax does not implement imageModel; use openai.imageModel or similar');
}

Type guard

function supportsImages(p: any): p is { imageModel: (id: string) => ImageModel } {
  try { p.imageModel('probe'); return true; } catch { return false; }
}

Try / catch

try {
  await generateImage({ model: provider.imageModel(id), prompt });
} catch (e) {
  if (NoSuchModelError.isInstance(e) && e.modelType === 'imageModel') {
    // switch to an image-capable provider
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling minimax.imageModel(id) directly, or using the minimax provider in generateImage({ model: ... }) / pipelines that resolve provider.imageModel.

Common situations: Assuming MiniMax support for image generation because the provider supports video, or refactoring shared image-generation code to swap providers without checking capability.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/32a23efc545d783f. Report an issue: GitHub.