vercel/ai · error · NoSuchModelError
No such embeddingModel: ${modelId}
Error message
No such embeddingModel: ${modelId} What it means
The z.ai (Zhipu) provider does not implement embedding models; its embeddingModel/textEmbeddingModel factories unconditionally throw NoSuchModelError with modelType 'embeddingModel'. Any attempt to obtain an embedding model from @ai-sdk/zai triggers this, since the provider only supports language models.
Source
Thrown at packages/zai/src/zai-provider.ts:93
`ai-sdk/zai/${VERSION}`,
);
const createLanguageModel = (modelId: ZaiChatModelId) =>
new ZaiChatLanguageModel(modelId, {
provider: 'zai.chat',
baseURL,
headers: getHeaders,
fetch: options.fetch,
});
const provider = (modelId: ZaiChatModelId) => createLanguageModel(modelId);
provider.specificationVersion = 'v4' as const;
provider.languageModel = createLanguageModel;
provider.chat = createLanguageModel;
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 zai = createZai();
View on GitHub (pinned to 69428b1f8b)
Solutions
- Use a provider with embedding support (e.g. @ai-sdk/openai textEmbeddingModel) for embed/embedMany.
- Keep zai for chat/language models only and split your model configuration by capability.
- Add an explicit capability check or registry so embedding requests never route to zai.
Example fix
// before
const { embedding } = await embed({ model: zai.textEmbeddingModel('embedding-3'), value });
// after
import { createOpenAI } from '@ai-sdk/openai';
const openai = createOpenAI();
const { embedding } = await embed({ model: openai.textEmbeddingModel('text-embedding-3-small'), value }); Defensive patterns
Strategy: fallback
Validate before calling
const ZAI_SUPPORTS_EMBEDDINGS = false;
function getEmbeddingModel(preferred: 'zai' | 'openai') {
return preferred === 'zai' && !ZAI_SUPPORTS_EMBEDDINGS
? openai.textEmbeddingModel('text-embedding-3-small')
: /* other */ null;
} Type guard
function supportsEmbeddings(provider: any): boolean {
return typeof provider?.textEmbeddingModel === 'function' && provider.specificationVersion != null &&
!/NoSuchModelError/.test(provider.textEmbeddingModel.toString());
} Try / catch
try {
return await embed({ model: zai.textEmbeddingModel(id), value });
} catch (e) {
if (NoSuchModelError.isInstance(e)) {
return await embed({ model: openai.textEmbeddingModel('text-embedding-3-small'), value });
}
throw e;
} Prevention
- Route embedding workloads only to providers that document embedding support.
- Maintain a provider capability matrix in your app config.
- Add compile-time narrowing: never accept `zai` as an embedding model source in your wrapper's types.
When it happens
Trigger: zai.embeddingModel('embedding-3') or zai.textEmbeddingModel('...') called directly; embed()/embedMany() with model: zai('some-model'); generic provider-selection code mapping 'zai' to an embedding request.
Common situations: Assuming every AI SDK provider supports embeddings; migrating an embedding pipeline from openai/mistral to zai; capability-agnostic model factory code in multi-provider apps.
Related errors
- AI_NoSuchModelError
- embeddingModel
- ElevenLabs does not provide embedding models
- AI_NoSuchModelError
- No such embeddingModel: ${modelId}
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/1790d142ab564b96.
Report an issue: GitHub.