vercel/ai · error · NoSuchModelError

AI_NoSuchModelError

AI_NoSuchModelError

Error message

No such embeddingModel: ${modelId}

What it means

The Black Forest Labs provider only implements image and video models. Its `embeddingModel` factory deliberately throws `NoSuchModelError` (code AI_NoSuchModelError) for any modelId, because BFL offers no text-embedding models. The same error surfaces via the `textEmbeddingModel` alias.

Source

Thrown at packages/black-forest-labs/src/black-forest-labs-provider.ts:121

      baseURL: baseURL ?? defaultBaseURL,
      headers: getHeaders,
      fetch: options.fetch,
      pollIntervalMillis: options.pollIntervalMillis,
      pollTimeoutMillis: options.pollTimeoutMillis,
    });

  const createVideoModel = (modelId: BlackForestLabsVideoModelId) =>
    new BlackForestLabsVideoModel(modelId, {
      provider: 'black-forest-labs.video',
      baseURL: baseURL ?? defaultBaseURL,
      headers: getHeaders,
      fetch: options.fetch,
      pollIntervalMillis: options.pollIntervalMillis,
      pollTimeoutMillis: options.pollTimeoutMillis,
    });

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

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

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Use a provider that implements embeddings (e.g. @ai-sdk/openai, @ai-sdk/amazon-bedrock, @ai-sdk/google) for embed/embedMany.
  2. Remove the embed/embedMany call path that resolves models via the BFL provider.
  3. If you intended image generation, switch to `bfl.image(modelId)` / `bfl.imageModel(modelId)`.

Example fix

// before
import { createBlackForestLabs } from '@ai-sdk/black-forest-labs';
const bfl = createBlackForestLabs({ apiKey });
const { embedding } = await embed({ model: bfl.textEmbeddingModel('x'), value: 'hi' });

// after
import { createOpenAI } from '@ai-sdk/openai';
const openai = createOpenAI({ apiKey: process.env.OPENAI_API_KEY });
const { embedding } = await embed({ model: openai.textEmbeddingModel('text-embedding-3-small'), value: 'hi' });
Defensive patterns

Strategy: validation

Validate before calling

const EMBEDDING_CAPABLE = new Set(['openai', 'amazon-bedrock', 'google', 'mistral', 'cohere']);
function assertEmbeddingProvider(providerName: string) {
  if (!EMBEDDING_CAPABLE.has(providerName))
    throw new Error(`${providerName} does not support embedding models; use openai/google/etc.`);
}

Type guard

function supportsEmbeddings(p: unknown): boolean {
  const candidate = p as { textEmbeddingModel?: unknown; imageModel?: unknown };
  // BFL exposes image/video only; its embedding factories always throw
  return typeof candidate?.textEmbeddingModel === 'function' && !('imageModel' in candidate);
}

Try / catch

try {
  return await embed({ model: provider.textEmbeddingModel(id), value });
} catch (e: any) {
  if (e?.name === 'NoSuchModelError' || e?.code === 'AI_NoSuchModelError') {
    throw new Error(`${providerName} does not support embeddings: ${e.message}`);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling `bfl.embeddingModel('any-id')`, `bfl.textEmbeddingModel('any-id')`, or `embed`/`embedMany` with a model resolved from the BFL provider — for any modelId string, since no embedding model exists.

Common situations: Copy-pasting provider setup from an OpenAI/other-provider example and swapping the provider to BFL while keeping embed() calls; mistakenly assuming BFL supports embeddings; a shared model-factory registry routing embedding requests to the wrong provider.

Related errors


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