vercel/ai · error · NoSuchModelError

AI_NoSuchModelError

AI_NoSuchModelError

Error message

No such imageModel: ${modelId}

What it means

Alibaba's provider factory does not implement an imageModel factory, so provider.imageModel(modelId) unconditionally throws NoSuchModelError. The provider object implements the LanguageModelV4 provider spec where imageModel is optional and explicitly declared unsupported here.

Source

Thrown at packages/alibaba/src/alibaba-provider.ts:181

    if (new.target) {
      throw new Error(
        'The Alibaba model function cannot be called with the new keyword.',
      );
    }

    return createLanguageModel(modelId);
  };

  provider.specificationVersion = 'v4' as const;
  provider.languageModel = createLanguageModel;
  provider.chatModel = createLanguageModel;
  provider.embedding = createEmbeddingModel;
  provider.embeddingModel = createEmbeddingModel;
  provider.video = createVideoModel;
  provider.videoModel = createVideoModel;

  provider.imageModel = (modelId: string) => {
    throw new NoSuchModelError({ modelId, modelType: 'imageModel' });
  };

  return provider;
}

export const alibaba = createAlibaba();

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Use alibaba.video('wan2.2-...') for video generation or check the provider's supported factory methods
  2. Call the DashScope image API directly for Alibaba image models
  3. Switch to a provider that implements imageModel (e.g. openai.image(...))

Example fix

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

Strategy: validation

Validate before calling

if (typeof (alibaba as any).imageModel !== 'function' || true) {
  // alibaba.imageModel always throws; use a provider that supports images
}

Type guard

function supportsImageModel(p: unknown): boolean {
  try { (p as any).imageModel?.('probe'); return true; } catch { return false; }
}

Try / catch

try {
  model = alibaba.imageModel(modelId);
} catch (e) {
  if (NoSuchModelError.isInstance(e) && e.modelType === 'imageModel') {
    model = otherProvider.image(modelId); // fallback provider
  } else throw e;
}

Prevention

When it happens

Trigger: Calling alibaba.image('wanx-...') or alibaba.imageModel('wanx-...') — any imageModel lookup on the alibaba provider.

Common situations: Assuming every provider supports image generation because other providers (e.g. openai) do; copy-pasting model factory code across providers.

Related errors


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