Skip to content

AI SDK ​

@originalvoices/ai-sdk gives your Vercel AI SDK agent tools to ask Digital Twins of real people mid-conversation.

bash
npm install @originalvoices/ai-sdk   # needs ai ^6 and zod ^4

Set ORIGINALVOICES_API_KEY in your environment, then add the tools:

ts
import { generateText, stepCountIs } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { askTwins, listAudiences, listStudies } from "@originalvoices/ai-sdk";

const { text } = await generateText({
  model: anthropic("claude-sonnet-5-5"),
  tools: { askTwins, listAudiences, listStudies },
  stopWhen: stepCountIs(5),
  prompt:
    "Ask 30-45 year old professionals what they struggle with most when " +
    "trying to stay fit, then suggest 3 app features based on their answers.",
});

askTwins ​

Asks up to 15 open and choice questions with POST /v1/ask. Pass exactly one of audience, audienceId or studyId.

InputTypeDescription
questionsarrayA string is an open question. { question, choices, multiple? } is a choice question with 2–20 options.
audiencestringWho to ask, in plain words
audienceIdstringA saved audience, from listAudiences
studyIdstringA study, from listStudies; its participants answer
filterstringWith studyId: narrow participants in plain words
sampleSizenumberHow many participants answer (25 by default for a described audience)

It returns the data of POST /v1/ask: each Twin's answers with a low, medium or high confidence, plus per-option results for choice questions.

listAudiences and listStudies ​

Let the model find your saved audiences and studies, so it can pass their ids to askTwins. Leave them out if you only want described audiences.

npm · GitHub