vercel/ai · error
params.values must be an array of strings
Error message
params.values must be an array of strings
What it means
The embedding model's doEmbed validates params.values is an array before sending to the performance client. A non-array values argument throws this error — a defensive guard against malformed embed() input.
Solutions
- Pass values as string[], e.g. ['first text', 'second text'].
- Coerce single strings to an array before calling embed().
- Ensure the values argument is defined and not misnamed.
Example fix
// before
await embed({ model, values: 'hello world' });
// after
await embed({ model, values: ['hello world'] }); Defensive patterns
Strategy: validation
Validate before calling
function assertStringArray(values) {
if (!Array.isArray(values) || values.some(v => typeof v !== 'string')) {
throw new TypeError('values must be string[]');
}
}
assertStringArray(values); Type guard
function isStringArray(v: unknown): v is string[] {
return Array.isArray(v) && v.every(x => typeof x === 'string');
} Try / catch
try {
await embed({ model, values });
} catch (e) {
if (e instanceof Error && e.message === 'params.values must be an array of strings') {
// coerce: values = Array.isArray(values) ? values : [String(values)];
}
} Prevention
- Always pass an array to embed(), even for a single string.
- Type the values parameter as string[] end-to-end.
- Validate dynamic input shape before calling embed().
When it happens
Trigger: Calling embed({ model: baseten.textEmbeddingModel(...), values: 'string' }) or values: undefined / a non-array value.
Common situations: Passing a single string instead of an array; passing a variable that is undefined due to upstream bug; dynamic values built incorrectly.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Invalid auth: expected an authentication mode or a flat…
- No model URL provided for embeddings. Please set modelURL…
- Not supported. You must use a /sync or /sync/v1 endpoint…
- ACP credentialEnv and credentialBrokering must be…
- ACP credentialEnv and credentialBrokering must be…
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/7bc97da1185bc94f.
Report an issue: GitHub.
Appendix: source
Thrown at packages/baseten/src/baseten-provider.ts:267
if (!options.performanceClient) {
return model;
}
// Opted in to the native client. It appends /v1 itself, so hand it the bare
// /sync form.
const performanceClient = new options.performanceClient(
customURL.replace('/sync/v1', '/sync'),
loadApiKey({
apiKey: options.apiKey,
environmentVariableName: 'BASETEN_API_KEY',
description: 'Baseten API key',
}),
);
model.doEmbed = async params => {
if (!params.values || !Array.isArray(params.values)) {
throw new Error('params.values must be an array of strings');
}
const response = await performanceClient.embed(
params.values,
// model_id is for Model APIs; dedicated deployments ignore it.
modelId ?? 'embeddings',
);
return {
embeddings: response.data.map(item => item.embedding),
// The native client types its response as `any`; only report usage when
// a token count is actually present rather than `{ tokens: undefined }`.
usage:
typeof response.usage?.total_tokens === 'number'
? { tokens: response.usage.total_tokens }
: undefined,
response: { headers: {}, body: response },
warnings: [],View on GitHub (pinned to 69428b1f8b)