vercel/ai · error · NoSuchModelError

AI_NoSuchModelError

AI_NoSuchModelError

Error message

No such embeddingModel: ${modelId}

What it means

The Luma provider does not implement embedding models; calling luma.embeddingModel(modelId) or luma.textEmbeddingModel(modelId) intentionally throws NoSuchModelError (code AI_NoSuchModelError). Luma is an image/video generation provider, so any embedding request through it is a programming error surfaced early with the requested modelId in the message.

Source

Thrown at packages/luma/src/luma-provider.ts:80

          apiKey: options.apiKey,
          environmentVariableName: 'LUMA_API_KEY',
          description: 'Luma',
        })}`,
        ...options.headers,
      },
      `ai-sdk/luma/${VERSION}`,
    );

  const createImageModel = (modelId: LumaImageModelId) =>
    new LumaImageModel(modelId, {
      provider: 'luma.image',
      baseURL: baseURL ?? defaultBaseURL,
      headers: getHeaders,
      fetch: options.fetch,
    });

  const embeddingModel = (modelId: string) => {
    throw new NoSuchModelError({
      modelId,
      modelType: 'embeddingModel',
    });
  };

  return {
    specificationVersion: 'v4' as const,
    image: createImageModel,
    imageModel: createImageModel,
    languageModel: (modelId: string) => {
      throw new NoSuchModelError({
        modelId,
        modelType: 'languageModel',
      });
    },
    embeddingModel,
    textEmbeddingModel: embeddingModel,
  };

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Use a provider that implements embeddings, e.g. openai.textEmbeddingModel('text-embedding-3-small') or providers like amazon-bedrock/cohere/mistral.
  2. Check the provider's exported surface (imageModel vs textEmbeddingModel) before wiring embed()/embedMany().
  3. Centralize provider selection so embedding code only receives embedding-capable providers.
  4. If a capability check is needed, guard with instanceof/feature detection on the returned model's specificationVersion/type.

Example fix

// before
const model = luma.textEmbeddingModel('text-embedding-1');
const { embedding } = await embed({ model, value: 'hello' });
// after
import { openai } from '@ai-sdk/openai';
const model = openai.textEmbeddingModel('text-embedding-3-small');
const { embedding } = await embed({ model, value: 'hello' });
Defensive patterns

Strategy: try-catch

Validate before calling

function supportsEmbeddings(provider) {
  try {
    return typeof provider.textEmbeddingModel === 'function' &&
      // probe a call; Luma's version always throws
      (provider.textEmbeddingModel('probe'), true);
  } catch {
    return false;
  }
}

Type guard

function isNoSuchModelError(e: unknown): e is { code: 'AI_NoSuchModelError'; modelId: string; modelType: string } {
  return typeof e === 'object' && e !== null && (e as any).code === 'AI_NoSuchModelError';
}

Try / catch

import { NoSuchModelError } from 'ai';
try {
  const model = luma.textEmbeddingModel('any');
} catch (e) {
  if (NoSuchModelError.isInstance(e)) {
    throw new Error(`Provider does not support ${e.modelType}; use e.g. openai.textEmbeddingModel()`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling luma.embedding('any-id') or luma.textEmbeddingModel('any-id') and passing the result to embed()/embedMany(), e.g. after copy-pasting provider setup code from an OpenAI example.

Common situations: Swapping model providers in a RAG pipeline and assuming all providers expose embeddings; auto-selecting a provider by name without checking capability; typos leading to the wrong provider object being used.

Related errors


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