Method Reference

Complete reference for all AskVerdict SDK client methods — signatures, parameters, return types, and examples.

13 min read
Share

Complete reference for every public method on AskVerdictClient. Methods are grouped by domain. All methods are async and return a Promise unless noted otherwise.

All methods throw an AskVerdictError on API or network failure. See Error Handling at the end of this page for catch patterns.


Verdicts

createVerdict

Create a new AI debate and receive its ID and SSE stream URL. The debate runs asynchronously — use streamVerdict to follow progress in real time.

typescript
async createVerdict(params: CreateDebateParams): Promise<CreateDebateResult>
NameTypeRequiredDescription
params.questionstringRequiredThe question or proposition to debate.
params.mode"fast" | "balanced" | "thorough" | "analytical"OptionalDebate depth. Defaults to "fast".
params.agentCountnumberOptionalNumber of AI agents to involve (2–6).
params.maxRoundsnumberOptionalMaximum debate rounds before forced synthesis.
params.enableSearchbooleanOptionalAllow agents to run web searches during the debate.
params.contextstringOptionalBackground information provided to all agents.
params.presetstringOptionalNamed debate preset (e.g. "business-decision").
params.skipCachebooleanOptionalForce a fresh debate even if a cached result exists.

Returns CreateDebateResult

FieldTypeDescription
idstringDebate ID (use this for all subsequent calls)
statusstringInitial status ("pending")
streamUrlstringFull SSE URL to stream events
debateIdstringDeprecated alias for id
typescript
const result = await client.createVerdict({
  question: "Should we adopt Kubernetes?",
  mode: "balanced",
});
 
console.log(result.id);        // "dbt_abc123"
console.log(result.streamUrl); // "https://api.askverdict.ai/v1/verdicts/dbt_abc123/stream"

getVerdict

Retrieve a single debate by ID, including its full verdict when complete.

typescript
async getVerdict(id: string): Promise<{ verdict: DebateResponse }>
NameTypeRequiredDescription
idstringRequiredThe debate ID.

Returns { verdict: DebateResponse } — see the DebateResponse shape below.

DebateResponse fields:

FieldTypeDescription
idstringDebate ID
questionstringOriginal question
statusDebateStatusactive | completed | failed | paused | pending | running
verdictVerdict | nullFull verdict (null if not yet completed)
costDebateCostRecord | nullToken cost breakdown
modestring | nullDebate mode used
agentCountnumber | nullNumber of agents
roundCountnumber | nullActual rounds completed
fundingSource"free_tier" | "user_credits" | "byok" | nullHow the debate was funded
isPublicbooleanWhether the debate is publicly visible
createdAtstringISO 8601 timestamp
completedAtstring | nullISO 8601 completion timestamp
typescript
const { verdict } = await client.getVerdict("dbt_abc123");
 
if (verdict.status === "completed" && verdict.verdict) {
  console.log(verdict.verdict.recommendation.recommendation);
  console.log(`Confidence: ${Math.round(verdict.verdict.confidence * 100)}%`);
}

listVerdicts

List debates for the authenticated user with pagination and status filtering.

typescript
async listVerdicts(params?: ListDebatesParams): Promise<ListDebatesResult>
NameTypeRequiredDescription
params.pagenumberOptionalPage number (1-indexed). Defaults to 1.
params.pageSizenumberOptionalResults per page. Defaults to 20.
params.limitnumberOptionalAlias for pageSize.
params.statusDebateStatusOptionalFilter by status: active, completed, failed, paused, pending, running.

Returns ListDebatesResult:

FieldTypeDescription
debatesDebateResponse[]Array of debate objects
totalnumberTotal matching debates
pagenumberCurrent page
pageSizenumberResults per page
hasMorebooleanWhether more pages exist
typescript
const result = await client.listVerdicts({ pageSize: 20 });
 
for (const debate of result.debates) {
  console.log(debate.id, debate.status, debate.question);
}

deleteVerdict

Permanently delete a debate. This action cannot be undone.

typescript
async deleteVerdict(id: string): Promise<void>
NameTypeRequiredDescription
idstringRequiredThe debate ID to delete.
typescript
await client.deleteVerdict("dbt_abc123");
// Resolves with void; throws AskVerdictError on failure

streamVerdict

Stream SSE events for a running or completed debate. Returns an AsyncGenerator — iterate with for await.

typescript
async *streamVerdict(id: string): AsyncGenerator<StreamEvent>
NameTypeRequiredDescription
idstringRequiredThe debate ID to stream.

StreamEvent shape:

FieldTypeDescription
idstringSSE event ID
typestringEvent type (see table below)
dataunknownEvent payload (usually an object)
timestampnumberClient-side Date.now() when received

Common event types:

typeWhen fired
debate:startDebate begins processing
agent:thinkingAn agent is composing a turn
agent:argumentAn agent published an argument
agent:searchAn agent performed a web search
verdict:startSynthesis phase begins
verdict:completeFull verdict is ready
debate:completeDebate is fully done
debate:errorFatal error during debate
cost:updateRunning token cost update
stream:endStream closed by server
typescript
for await (const event of client.streamVerdict("dbt_abc123")) {
  if (event.type === "agent:argument") {
    const data = event.data as { agentName: string; content: string };
    console.log(`${data.agentName}: ${data.content}`);
  }
 
  if (event.type === "debate:complete") break;
}

streamVerdict uses the native fetch SSE reader. Ensure your environment supports fetch (Node 18+, Bun, or browsers). The generator does not automatically reconnect on drop — wrap in retry logic for long-running streams.


Voting

getVotes

Get vote tallies for all argument claims in a debate. If authenticated, each tally includes the caller's own vote.

typescript
async getVotes(debateId: string): Promise<VoteMap>
NameTypeRequiredDescription
debateIdstringRequiredThe debate ID.

Returns VoteMap — a Record<string, ClaimVoteTally> keyed by claim ID.

ClaimVoteTally:

FieldTypeDescription
agreenumberTotal agree votes
disagreenumberTotal disagree votes
userVoteVoteValue | undefinedCaller's own vote (authenticated only)
typescript
const votes = await client.getVotes("dbt_abc123");
 
for (const [claimId, tally] of Object.entries(votes)) {
  console.log(`${claimId}: +${tally.agree} / -${tally.disagree}`);
  if (tally.userVote) {
    console.log(`  Your vote: ${tally.userVote}`);
  }
}

castVote

Cast or update a vote on an argument claim. Pass "neutral" to remove an existing vote.

typescript
async castVote(debateId: string, claimId: string, vote: VoteValue): Promise<void>
NameTypeRequiredDescription
debateIdstringRequiredThe debate ID.
claimIdstringRequiredThe claim ID to vote on.
vote"agree" | "disagree" | "neutral"RequiredYour vote. Use "neutral" to remove a previous vote.
typescript
await client.castVote("dbt_abc123", "claim_xyz", "agree");

removeVote

Remove the authenticated user's vote on a specific claim.

typescript
async removeVote(debateId: string, claimId: string): Promise<void>
NameTypeRequiredDescription
debateIdstringRequiredThe debate ID.
claimIdstringRequiredThe claim ID to remove the vote from.
typescript
await client.removeVote("dbt_abc123", "claim_xyz");

Polls

getPolls

Get all polls for a debate, with vote tallies and (if authenticated) the caller's own vote per poll.

typescript
async getPolls(debateId: string): Promise<Poll[]>
NameTypeRequiredDescription
debateIdstringRequiredThe debate ID.

Returns Poll[]. Each Poll:

FieldTypeDescription
idstringPoll ID
debateIdstringParent debate
questionstringPoll question
optionsPollOption[]Array of { id, label }
status"open" | "closed"Whether voting is open
talliesRecord<string, number>Vote counts keyed by option ID
totalVotesnumberSum of all votes
userVotestring | nullOption ID the caller voted for
createdAtstringISO 8601
closedAtstring | nullISO 8601 or null if still open
typescript
const polls = await client.getPolls("dbt_abc123");
 
for (const poll of polls) {
  console.log(`${poll.question} (${poll.status})`);
  for (const option of poll.options) {
    const votes = poll.tallies[option.id] ?? 0;
    console.log(`  ${option.label}: ${votes} votes`);
  }
}

createPoll

Create a poll on a debate. Requires debate ownership.

typescript
async createPoll(debateId: string, question: string, options: string[]): Promise<Poll>
NameTypeRequiredDescription
debateIdstringRequiredThe debate ID.
questionstringRequiredThe poll question.
optionsstring[]RequiredPoll option labels. Minimum 2, maximum 6.
typescript
const poll = await client.createPoll(
  "dbt_abc123",
  "Which argument was most convincing?",
  ["The pro side — scalability wins", "The con side — cost is too high", "Neither"],
);
 
console.log(poll.id); // "poll_pqr789"

votePoll

Vote on a poll option.

typescript
async votePoll(debateId: string, pollId: string, optionId: string): Promise<void>
NameTypeRequiredDescription
debateIdstringRequiredThe debate ID.
pollIdstringRequiredThe poll ID.
optionIdstringRequiredThe ID of the option to vote for.
typescript
await client.votePoll("dbt_abc123", "poll_pqr789", "opt_001");

closePoll

Close a poll to prevent further votes. Requires debate ownership.

typescript
async closePoll(debateId: string, pollId: string): Promise<void>
NameTypeRequiredDescription
debateIdstringRequiredThe debate ID.
pollIdstringRequiredThe poll ID to close.
typescript
await client.closePoll("dbt_abc123", "poll_pqr789");

deletePoll

Delete a poll. Requires debate ownership.

typescript
async deletePoll(debateId: string, pollId: string): Promise<void>
NameTypeRequiredDescription
debateIdstringRequiredThe debate ID.
pollIdstringRequiredThe poll ID to delete.
typescript
await client.deletePoll("dbt_abc123", "poll_pqr789");

Outcomes

getOutcome

Get the recorded real-world outcome for a debate.

typescript
async getOutcome(debateId: string): Promise<OutcomeRecord>
NameTypeRequiredDescription
debateIdstringRequiredThe debate ID.

Returns OutcomeRecord:

FieldTypeDescription
idstringOutcome record ID
debateIdstringParent debate
actualOutcomestringText description of what actually happened
notesstring | nullOptional notes
verdictWasCorrectboolean | nullWhether the AI verdict matched reality
recordedAtstringISO 8601 timestamp
typescript
const outcome = await client.getOutcome("dbt_abc123");
 
if (outcome.verdictWasCorrect !== null) {
  console.log(`Verdict was ${outcome.verdictWasCorrect ? "correct" : "incorrect"}`);
}

submitOutcome

Submit a real-world outcome for a completed debate. Used to track AI prediction accuracy over time.

typescript
async submitOutcome(debateId: string, params: SubmitOutcomeParams): Promise<OutcomeRecord>
NameTypeRequiredDescription
debateIdstringRequiredThe debate ID.
params.actualOutcomestringRequiredDescription of what actually happened.
params.notesstringOptionalAdditional context or notes.
params.verdictWasCorrectbooleanOptionalWhether the AI verdict matched the actual outcome.
typescript
const outcome = await client.submitOutcome("dbt_abc123", {
  actualOutcome: "Adopted Kubernetes — deployment time down 40%",
  verdictWasCorrect: true,
  notes: "The scalability argument proved decisive.",
});

getPendingOutcomes

List debates with completed verdicts that have no outcome recorded yet.

typescript
async getPendingOutcomes(): Promise<OutcomeRecord[]>
typescript
const pending = await client.getPendingOutcomes();
 
console.log(`${pending.length} debates awaiting outcome recording`);
for (const p of pending) {
  console.log(p.debateId);
}

getOutcomeHistory

Get paginated outcome recording history, optionally filtered by domain.

typescript
async getOutcomeHistory(
  opts?: { limit?: number; offset?: number; domain?: string }
): Promise<OutcomeRecord[]>
NameTypeRequiredDescription
opts.limitnumberOptionalMaximum number of records to return.
opts.offsetnumberOptionalNumber of records to skip (for pagination).
opts.domainstringOptionalFilter outcomes by domain tag.
typescript
const history = await client.getOutcomeHistory({ limit: 50, domain: "business" });

Billing

getBalance

Get the authenticated user's credit balance and plan.

typescript
async getBalance(): Promise<BalanceInfo>

Returns BalanceInfo:

FieldTypeDescription
creditBalancenumberRemaining credits
planstringCurrent plan (free, byok, byok_pro, etc.)
typescript
const balance = await client.getBalance();
 
console.log(`${balance.creditBalance} credits remaining on the ${balance.plan} plan`);

search

Search your debates by keyword with sorting and filtering.

typescript
async search(query: string, opts?: SearchParams): Promise<SearchResult>
NameTypeRequiredDescription
querystringRequiredFull-text search query.
opts.type"debates" | "verdicts"OptionalRestrict results to debates or verdicts.
opts.sort"relevance" | "date" | "popularity"OptionalSort order. Defaults to "relevance".
opts.pagenumberOptionalPage number. Defaults to 1.
opts.limitnumberOptionalResults per page. Defaults to 20.
opts.statusstringOptionalFilter by debate status.
opts.modestringOptionalFilter by debate mode.

Returns SearchResult:

FieldTypeDescription
resultsSearchResultItem[]Matching debates
totalnumberTotal matches
pagenumberCurrent page
totalPagesnumberTotal page count
typescript
const result = await client.search("kubernetes microservices");
 
for (const item of result.results) {
  console.log(item.question, item.status);
}

User

getMe

Get the authenticated user's profile.

typescript
async getMe(): Promise<UserProfile>

Returns UserProfile:

FieldTypeDescription
idstringUser ID
namestringDisplay name
emailstringEmail address
imagestring | nullAvatar URL
planstringCurrent plan
biostring | nullProfile bio
locationstring | nullLocation string
createdAtstringISO 8601 join date
typescript
const me = await client.getMe();
console.log(`Hello, ${me.name} (${me.plan} plan)`);

getUsage

Get debate and credit usage for the authenticated user's current billing period.

typescript
async getUsage(): Promise<UsageInfo>

Returns UsageInfo:

FieldTypeDescription
planstringCurrent plan
debatesThisMonthnumberDebates run this month
debatesLimitnumber | nullMonthly cap (null = unlimited)
creditsRemainingnumberCredits left this period
freeDebateResetAtstring | nullWhen free allowance resets
typescript
const usage = await client.getUsage();
const cap = usage.debatesLimit ?? "unlimited";
console.log(`${usage.debatesThisMonth} / ${cap} debates this month`);

getApiUser

Get the user profile associated with the current API key (v1 endpoint, no session required).

typescript
async getApiUser(): Promise<UserProfile>
typescript
const user = await client.getApiUser();

getApiUsage

Get API key request usage stats for the current billing period.

typescript
async getApiUsage(): Promise<ApiKeyUsage>

Returns ApiKeyUsage:

FieldTypeDescription
keyIdstringThe API key ID
periodstringBilling period label
totalRequestsnumberTotal requests this period
byEndpointRecord<string, number>Per-endpoint request counts
rateLimitnumberRequests per minute limit
typescript
const usage = await client.getApiUsage();
console.log(`${usage.totalRequests} total API requests this period`);

Stats

getDashboard

Get aggregated dashboard statistics, optionally scoped to a workspace.

typescript
async getDashboard(workspaceId?: string): Promise<DashboardStats>
NameTypeRequiredDescription
workspaceIdstringOptionalScope stats to a specific workspace.

Returns DashboardStats:

FieldTypeDescription
totalDebatesnumberAll-time debate count
debatesThisWeeknumberDebates in the last 7 days
weeklyActivitynumber[]Daily counts for the last 7 days
modeDistributionRecord<string, number>Debate count per mode
averageCostnumberAverage USD cost per debate
currentStreaknumberCurrent daily debate streak
typescript
const stats = await client.getDashboard();
console.log(`${stats.totalDebates} debates total, ${stats.currentStreak} day streak`);

getScore

Get the authenticated user's decision accuracy score.

typescript
async getScore(): Promise<DecisionScore>

Returns DecisionScore:

FieldTypeDescription
overallAccuracynumberFraction correct (0–1)
totalDecisionsnumberTotal decisions tracked
correctPredictionsnumberNumber correct
brierScorenumber | nullCalibration score (lower is better)
calibrationScorenumber | nullCalibration fraction (0–1)
typescript
const score = await client.getScore();
console.log(`Accuracy: ${Math.round(score.overallAccuracy * 100)}%`);

getStreak

Get the authenticated user's debate streak information and milestones.

typescript
async getStreak(): Promise<StreakInfo>

Returns StreakInfo:

FieldTypeDescription
currentStreaknumberCurrent consecutive-day streak
longestStreaknumberAll-time longest streak
totalDebatesnumberAll-time debate count
milestonesArray<{ count, reached, reachedAt? }>Streak milestone records
typescript
const streak = await client.getStreak();
console.log(`Current streak: ${streak.currentStreak} days`);
console.log(`Longest ever: ${streak.longestStreak} days`);

Utility

health

Check API health. No authentication required.

typescript
async health(): Promise<HealthResponse>

Returns HealthResponse:

FieldTypeDescription
status"ok" | "degraded" | "down"API health status
servicestringService name
versionstringAPI version
timestampstringServer timestamp
typescript
const client = new AskVerdictClient(); // no auth needed
const health = await client.health();
 
if (health.status !== "ok") {
  console.warn(`API is ${health.status}`);
}

Deprecated Aliases

These methods still work but are deprecated. Use their replacements.

DeprecatedReplacement
createDebate(params)createVerdict(params)
getDebate(id)getVerdict(id) — note: returns DebateResponse directly, not wrapped
listDebates(params)listVerdicts(params)
deleteDebate(id)deleteVerdict(id)
streamDebate(id)streamVerdict(id)

Error Handling

All methods throw AskVerdictError on failure. Inspect .code and .status for structured handling.

typescript
import { AskVerdictClient, AskVerdictError } from "@askverdict/sdk";
 
const client = new AskVerdictClient({ apiKey: process.env.ASKVERDICT_API_KEY });
 
try {
  const result = await client.createVerdict({ question: "..." });
} catch (error) {
  if (error instanceof AskVerdictError) {
    console.error(`[${error.code}] ${error.message}`);
    // error.status  → HTTP status (401, 422, 429, etc.)
    // error.details → extra context from the API
  } else {
    throw error; // re-throw unexpected errors
  }
}

Common error codes:

CodeHTTPMeaning
NETWORK_ERRORFetch failed (DNS, timeout, offline)
PARSE_ERRORNon-JSON API response
HTTP_ERRORvariesGeneric HTTP error
API_ERRORvariesStructured API error with code from server
STREAM_ERRORSSE stream failed to open or body was empty

Rate limit errors arrive as HTTP 429. Inspect error.status === 429 to implement exponential back-off.

Was this page helpful?