{"record":{"id":"7bc97da1185bc94f","repo":"vercel/ai","slug":"params-values-must-be-an-array-of-strings","errorCode":null,"errorMessage":"params.values must be an array of strings","messagePattern":"params\\.values must be an array of strings","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/baseten/src/baseten-provider.ts","lineNumber":267,"sourceCode":"\n    if (!options.performanceClient) {\n      return model;\n    }\n\n    // Opted in to the native client. It appends /v1 itself, so hand it the bare\n    // /sync form.\n    const performanceClient = new options.performanceClient(\n      customURL.replace('/sync/v1', '/sync'),\n      loadApiKey({\n        apiKey: options.apiKey,\n        environmentVariableName: 'BASETEN_API_KEY',\n        description: 'Baseten API key',\n      }),\n    );\n\n    model.doEmbed = async params => {\n      if (!params.values || !Array.isArray(params.values)) {\n        throw new Error('params.values must be an array of strings');\n      }\n\n      const response = await performanceClient.embed(\n        params.values,\n        // model_id is for Model APIs; dedicated deployments ignore it.\n        modelId ?? 'embeddings',\n      );\n\n      return {\n        embeddings: response.data.map(item => item.embedding),\n        // The native client types its response as `any`; only report usage when\n        // a token count is actually present rather than `{ tokens: undefined }`.\n        usage:\n          typeof response.usage?.total_tokens === 'number'\n            ? { tokens: response.usage.total_tokens }\n            : undefined,\n        response: { headers: {}, body: response },\n        warnings: [],","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/baseten/src/baseten-provider.ts#L249-L285","documentation":"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.","triggerScenarios":"Calling embed({ model: baseten.textEmbeddingModel(...), values: 'string' }) or values: undefined / a non-array value.","commonSituations":"Passing a single string instead of an array; passing a variable that is undefined due to upstream bug; dynamic values built incorrectly.","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."],"exampleFix":"// before\nawait embed({ model, values: 'hello world' });\n// after\nawait embed({ model, values: ['hello world'] });","handlingStrategy":"validation","validationCode":"function assertStringArray(values) {\n  if (!Array.isArray(values) || values.some(v => typeof v !== 'string')) {\n    throw new TypeError('values must be string[]');\n  }\n}\nassertStringArray(values);","typeGuard":"function isStringArray(v: unknown): v is string[] {\n  return Array.isArray(v) && v.every(x => typeof x === 'string');\n}","tryCatchPattern":"try {\n  await embed({ model, values });\n} catch (e) {\n  if (e instanceof Error && e.message === 'params.values must be an array of strings') {\n    // coerce: values = Array.isArray(values) ? values : [String(values)];\n  }\n}","preventionTips":["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()."],"tags":["validation","embeddings","baseten","typescript"],"backgroundTag":"invalid-argument-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}