Skip to content

AI SDK

The OriginalVoices AI SDK provides a Vercel AI SDK tool that gives your AI applications access to real-time audience research through Digital Twins.

Use this when building custom AI applications with Next.js, Node.js, or any JavaScript/TypeScript backend.

Installation

bash
npm install @originalvoices/ai-sdk

Peer Dependencies: This package requires ai (^6.0.0) and zod (^4.0.0). If you're using the Vercel AI SDK, you likely already have these installed.

Setup

  1. Get your API key from platform.originalvoices.ai

  2. Set your API key as an environment variable:

env
ORIGINALVOICES_API_KEY=your_api_key_here

Usage

typescript
import { generateText } from 'ai';
import { askTwins } from '@originalvoices/ai-sdk';

const result = await generateText({
  model: yourModel, // e.g., openai('gpt-4o'), anthropic('claude-sonnet-4-20250514'), etc.
  tools: { askTwins },
  prompt: 'I want to understand what influences UK fitness enthusiasts aged 18-30 when buying new running shoes',
});

console.log(result.text);

Tool: askTwins

Gather insights from a specific audience through Digital Twins.

Parameters

ParameterTypeRequiredDescription
audiencestringYesThe target demographic or group to gather insights from
questionsstring[]YesQuestions to ask the audience

Response

typescript
{
  data: {
    answers: Array<Array<{
      answer: string;
      confidence: number;
    }>>;
  };
  requestId: string;
}

Example

typescript
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { askTwins } from '@originalvoices/ai-sdk';

async function getProductInsights() {
  const result = await generateText({
    model: openai('gpt-4o'),
    tools: { askTwins },
    maxSteps: 5,
    prompt: `
      I'm launching a fitness app for busy professionals.
      Use askTwins to understand what 30-45 year old professionals
      struggle with most when trying to stay fit, then give me
      3 feature ideas based on their responses.
    `,
  });

  return result.text;
}

Powered by OriginalVoices