Skip to content

Quickstart Guide

Get up and running with the OriginalVoices API in minutes. This guide will walk you through installation, authentication, and your first API call.

Installation

Install the originalvoices npm package:

bash
npm install originalvoices

Authentication

Before you can use the API, you'll need an API key. Get your API key from the OriginalVoices Platform.

Once you have your API key, you can initialize the client. If you don't pass an apiKey to the constructor, it will automatically fallback to the ORIGINALVOICES_API_KEY environment variable:

javascript
import { OriginalVoices } from "originalvoices";

const client = new OriginalVoices({
  apiKey: process.env.ORIGINALVOICES_API_KEY,
});

API Key Security

Never commit your API key to version control. Use environment variables or a secrets management service.

Getting Insights

OriginalVoices provides two ways to gather insights from your target audience. Each endpoint is designed for different research needs, from open-ended questions to single and multiple choice questions.

Ask/Open

Use to ask any open-ended question. For the response, you will get raw answers from each Digital Twin, giving you direct access to individual responses.

When to use

Best for exploratory research, message testing, product feedback, or when you want to understand why something matters beyond purely measuring it quantitatively.

typescript
const { data } = await client.ask.open({
  audiencePrompt: "UK, 18-30, fitness enthusiasts",
  question: "When purchasing running shoes, what's most important to you?",
});

console.log({ data });

The response includes:

  • answers: Array of raw answers from Digital Twins, each containing:
    • answer: The free-text response from the Digital Twin
    • confidence: Score from 0 to 1 representing confidence in the answer correctness

Ask/Choices

Use to ask single or multipe choice questions. For the response, you will get a quantitative breakdown of the predefined answer options, including percentages for each answer choice.

When to use

Use when you want measurable preferences or decisions - such as feature prioritisation, yes/no responses, or option testing.

typescript
const { data } = await client.ask.choices({
  audiencePrompt: "US, 25-45, tech professionals",
  question:
    "Which of the following is most important when buying running shoes?",
  choices: ["Price", "Comfort", "Style", "Durability"],
  isMultipleChoice: false,
});

console.log({ data });

The response includes:

  • choices: Array of answer options, each containing:
    • choice: The option text
    • percentage: Percentage of responses that selected this option

Rate limiting

The API enforces rate limits to ensure fair usage and system stability. Default rate limits are:

  • 60 requests per minute (1 request per second)
  • 10,000 requests per day

When you exceed these limits, you'll receive a 429 Too Many Requests response. Rate limit information is included in response headers:

  • X-RateLimit-Limit: Maximum number of requests allowed
  • X-RateLimit-Remaining: Number of requests remaining in the current window
  • X-RateLimit-Reset: Time when the rate limit resets (Unix timestamp)
typescript
try {
  const { data } = await client.ask.open({
    audiencePrompt: "US, 25-45, tech professionals",
    question: "What features matter most to you in productivity tools?",
  });
} catch (error) {
  if (error.status === 429) {
    console.error(
      "Rate limit exceeded. Please wait before making more requests."
    );
    // Implement exponential backoff or wait for the reset time
  }
}

Rate Limit Best Practices

  • Implement exponential backoff when you receive 429 responses
  • Monitor the X-RateLimit-Remaining header to avoid hitting limits
  • For higher rate limits reach out to support@originalvoices.ai

Errors

HTTP API Errors

Status codeError codeDescription
400validationSchema validation failed. Includes field-level details in the details array.
400missing_audience_parameterEither audienceId or audiencePrompt is required.
400audience_title_existsAn audience with this title already exists for your organization.
401missing_api_keyMissing API key. Please provide an API key in the Authorization header.
401invalid_api_keyInvalid API key provided.
401api_key_revokedAPI key has been revoked.
401unauthorizedGeneric unauthorized error.
402insufficient_balanceYour account does not have enough credits to perform this action.
402payment_requiredGeneric payment required error.
404audience_not_foundAudience not found.
422insufficient_twinsInsufficient twins found. Please try again with a more specific prompt. Read more: https://docs.originalvoices.ai/errors/insufficient-twins.html
422policy_violationPolicy violated. Read more: https://docs.originalvoices.ai/question-guidelines.html
429rate_limit_exceededGeneric rate limit exceeded error.
500internal_server_errorAn internal server error occurred.

Notes:

  • Validation errors (400 with validation code) include a details array with field-level validation messages.
  • Generic error codes (e.g., bad_request, unauthorized) are used as fallbacks when a specific error code isn't provided.
  • All error responses follow the format: { requestId: string, data: null, error: { message: string, code: string, details?: Array<{field: string, message: string}> } }

Next Steps

  • Explore the How It Works page to understand the platform concepts
  • Check out the API Reference for detailed endpoint documentation
  • Experiment with different audiences to see how insights vary

Powered by OriginalVoices