Sign In

@getabrain/sdk

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@getabrain/sdk

Official Node/TypeScript SDK for the GetABrain.ai human-intelligence API

npmnpm
Version
0.1.1
Version published
Weekly downloads
71
42%
Maintainers
1
Weekly downloads
 
Created
Source

@getabrain/sdk

Official Node/TypeScript SDK for GetABrain.ai — real human judgment as an API.

Install

npm install @getabrain/sdk

Quickstart

import { GetABrain } from '@getabrain/sdk'

const gab = new GetABrain({ apiKey: 'gab_k_…', apiSecret: 'gab_s_…' })

// Submit a question (returns immediately)
const query = await gab.queries.create({
  type: 'ab_test',
  title: 'Which headline converts better?',
  content_data: {
    question: 'Which is more compelling?',
    variant_a: { description: 'Save 20% today' },
    variant_b: { description: 'Your future self will thank you' },
  },
  required_responses: 5,
  bid_amount_cents: 25,
})

// Wait for humans to answer (polls for you)
const responses = await gab.queries.waitForResponses(query.id, { minResponses: 5 })
console.log(responses.map((r) => r.response_data))

Errors

import { InsufficientBalanceError, RateLimitError } from '@getabrain/sdk'

try {
  await gab.queries.create(/* … */)
} catch (e) {
  if (e instanceof InsufficientBalanceError) {
    // top up your balance at https://getabrain.ai
  }
}

API

  • gab.queries.create(input) / .get(id) / .list({ status?, limit?, offset? }) / .cancel(id)
  • gab.queries.waitForResponses(id, { minResponses, timeoutMs?, pollIntervalMs? })
  • gab.responses.rate(queryId, responseId, { score, feedback_text? }) / .getRating(queryId, responseId)
  • gab.account.stats() / .balance()

Full reference: https://getabrain.ai/docs/api

The SDK types the 13 first-class query types. Two legacy types (custom, headline_test) exist server-side but are deprecated and intentionally not typed by the SDK — use a first-class type instead.

FAQs

Package last updated on 07 Jul 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts