{"record":{"id":"46ba9ca21b61d475","repo":"vercel/ai","slug":"embeddingmodel","errorCode":null,"errorMessage":"embeddingModel","messagePattern":"embeddingModel","errorType":"exception","errorClass":"NoSuchModelError","httpStatus":null,"severity":"error","filePath":"packages/anthropic/src/anthropic-provider.ts","lineNumber":195,"sourceCode":"    });\n\n  const provider = function (modelId: AnthropicModelId) {\n    if (new.target) {\n      throw new Error(\n        'The Anthropic model function cannot be called with the new keyword.',\n      );\n    }\n\n    return createChatModel(modelId);\n  };\n\n  provider.specificationVersion = 'v4' as const;\n  provider.languageModel = createChatModel;\n  provider.chat = createChatModel;\n  provider.messages = createChatModel;\n\n  provider.embeddingModel = (modelId: string) => {\n    throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n  };\n  provider.textEmbeddingModel = provider.embeddingModel;\n  provider.imageModel = (modelId: string) => {\n    throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n  };\n\n  provider.files = () =>\n    new AnthropicFiles({\n      provider: providerName,\n      baseURL,\n      headers: getHeaders,\n      fetch: options.fetch,\n    });\n\n  provider.skills = createSkills;\n\n  provider.tools = anthropicTools;\n","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/anthropic/src/anthropic-provider.ts#L177-L213","documentation":"The Anthropic provider only implements language (chat) models. Its `embeddingModel` factory is a stub that unconditionally throws NoSuchModelError with modelType 'embeddingModel' for any modelId passed. Anthropic does not offer an embeddings API through this SDK.","triggerScenarios":"Calling `anthropic.embeddingModel('some-id')` or `anthropic.textEmbeddingModel('some-id')`, or passing the anthropic provider to APIs that request an embedding model (e.g. `embed({ model: anthropic.embeddingModel(...) })`).","commonSituations":"Assuming provider parity with OpenAI and using Anthropic for embeddings; building a generic RAG pipeline that resolves embedding models from the wrong provider; swapping providers in shared config.","solutions":["Use a provider that implements embeddings, e.g. `createOpenAI(...).embedding('text-embedding-3-small')`, `@ai-sdk/amazon-bedrock`, or Google.","Move embedding generation to a separate provider instance and keep Anthropic only for language models."],"exampleFix":"// before\nimport { createAnthropic } from '@ai-sdk/anthropic';\nconst model = createAnthropic().embeddingModel('claude-embed');\n// after\nimport { createOpenAI } from '@ai-sdk/openai';\nconst model = createOpenAI().embedding('text-embedding-3-small');","handlingStrategy":"fallback","validationCode":"const embeddingProvider = supportsEmbeddings('anthropic')\n  ? anthropic\n  : createOpenAI();\nconst model = embeddingProvider.textEmbeddingModel('text-embedding-3-small');","typeGuard":"function hasEmbeddingModel(\n  p: any,\n): p is { textEmbeddingModel: (id: string) => unknown } {\n  return typeof p?.textEmbeddingModel === 'function' &&\n    !p.textEmbeddingModel.toString().includes('NoSuchModelError');\n}","tryCatchPattern":"try {\n  return anthropic.textEmbeddingModel(id);\n} catch (error) {\n  if (NoSuchModelError.isInstance(error) && error.modelType === 'embeddingModel') {\n    return openai.embedding('text-embedding-3-small');\n  }\n  throw error;\n}","preventionTips":["Check the provider's README/capability table before routing model types to it.","Maintain a per-capability provider map (language, embedding, image) in config.","Add integration tests for each model type your app resolves."],"tags":["unsupported-model-type","embeddings","provider-capability"],"backgroundTag":"model-type-not-supported","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}