vercel/ai · error · UnsupportedFunctionalityError
AI_UnsupportedFunctionalityError
AI_UnsupportedFunctionalityError
Error message
Alibaba embedding outputType 'sparse' is not supported because AI SDK embeddings require dense number arrays. Use 'dense' or 'dense&sparse' instead.
What it means
Alibaba embedding models can return sparse (index/value) vectors, but the AI SDK embed API only accepts dense number[] arrays. The provider therefore proactively rejects outputType 'sparse' with an UnsupportedFunctionalityError instead of returning data the SDK cannot represent. Use 'dense' or 'dense&sparse' (the SDK surfaces only the dense portion).
Source
Thrown at packages/alibaba/src/alibaba-embedding-model.ts:89
> {
if (values.length > this.maxEmbeddingsPerCall) {
throw new TooManyEmbeddingValuesForCallError({
provider: this.provider,
modelId: this.modelId,
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
values,
});
}
const alibabaOptions = await parseProviderOptions({
provider: 'alibaba',
providerOptions,
schema: alibabaEmbeddingModelOptions,
});
// TODO: Explore first-class sparse embedding support in AI SDK core.
if (alibabaOptions?.outputType === 'sparse') {
throw new UnsupportedFunctionalityError({
functionality: "Alibaba embedding outputType 'sparse'",
message:
"Alibaba embedding outputType 'sparse' is not supported because AI SDK embeddings require dense number arrays. Use 'dense' or 'dense&sparse' instead.",
});
}
const {
responseHeaders,
value: response,
rawValue,
} = await postJsonToApi({
url: `${this.config.baseURL}/services/embeddings/text-embedding/text-embedding`,
headers: combineHeaders(this.config.headers?.(), headers),
body: {
model: this.modelId,
input: {
texts: values,
},View on GitHub (pinned to 69428b1f8b)
Solutions
- Change the providerOptions outputType to 'dense' or 'dense&sparse'
- If sparse vectors are required, call the Alibaba/DashScope API directly outside the AI SDK
- Combine dense embeddings from the SDK with a separate sparse retrieval layer (e.g. BM25) instead
Example fix
// before
const { embedding } = await embed({
model: alibaba.embedding('text-embedding-v4'),
value: 'hello',
providerOptions: { alibaba: { outputType: 'sparse' } },
});
// after
const { embedding } = await embed({
model: alibaba.embedding('text-embedding-v4'),
value: 'hello',
providerOptions: { alibaba: { outputType: 'dense' } },
}); Defensive patterns
Strategy: validation
Validate before calling
if (opts.alibaba?.outputType === 'sparse') throw new Error('Use dense or dense&sparse outputType for AI SDK embeddings'); Type guard
function isDenseOutput(o: unknown): boolean {
const t = (o as { alibaba?: { outputType?: string } })?.alibaba?.outputType;
return t !== 'sparse';
} Try / catch
try {
await embed({ model, value, providerOptions });
} catch (e) {
if (UnsupportedFunctionalityError.isInstance(e)) {
// fall back to dense outputType
}
} Prevention
- Never set outputType: 'sparse' when using the AI SDK embed APIs
- Review providerOptions schemas before porting native DashScope options
- Read the alibaba-embedding-model docs on sparse vector limitations
When it happens
Trigger: Calling embed()/embedMany() with an alibaba.embedding(modelId) model while passing providerOptions alibaba.embeddingModelOptions with outputType: 'sparse' in doEmbed.
Common situations: Developers porting code that used Alibaba's native sparse vectors for keyword-style retrieval, or copying DashScope docs that recommend sparse output for search ranking, then wiring it into the AI SDK.
Related errors
- 'element streams in no-schema mode' functionality not suppor
- 'element streams in object mode' functionality not supported
- 'element streams in enum mode' functionality not supported.
- AI_UnsupportedFunctionalityError
- AI_UnsupportedFunctionalityError
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/6be812bf098226e2.
Report an issue: GitHub.