API & SDKS

Build any answer experience on our pipeline

Everything the widget does is available to your code: streaming RAG chat, hybrid search, feedback, suggested questions, and agents — via a public API and typed SDKs for web, React, React Native, and Node.

The developer surface

Same pipeline as the widget, full control of the experience

Client-key authenticated

Public API

  • SSE streaming chat with citations
  • Hybrid search with ranked, scored results
  • Suggested questions and related articles
  • Form deflection with confidence scores
  • Feedback and threaded conversations
Typed, small, focused

SDKs

  • @beforequery/sdk — browser, React Native, Node
  • @beforequery/react — component + headless hook
  • @beforequery/widget — embeddable Ask AI launcher
  • @beforequery/agents — agent graphs, MCP + A2A clients
  • Public keys for client-side, ID + secret for servers
Access you control

Keys & Scoping

  • bq_pk_ public keys safe for browsers
  • bq_ci_/bq_cs_ credentials for backend calls
  • Keys scoped per knowledge base
  • Allowed source groups narrow retrieval per key
  • Revoke instantly from the dashboard
From script tag to full custom

Choose your integration depth

Start with the widget's one script tag. Graduate to the React component when you want it native. Go headless with the hook or raw SDK when the design system demands it. Drop to the API for mobile, server-side, or anything else — every level runs the same retrieval, grounding, and citations.

  • Widget: one script tag, themeable, chat/sidebar/Cmd+K modes
  • React: <BeforeQueryChat /> or useBeforeQueryChat()
  • SDK: typed client for browser, React Native, and Node
  • API: SSE streaming chat and search over HTTPS
  • Agents: define and run agent graphs programmatically
@beforequery/sdk
import { BeforeQuery } from "@beforequery/sdk";

const bq = new BeforeQuery({
  clientKey: "bq_pk_...",
});

const stream = await bq.chat({
  knowledgeBaseId: "kb_abc123",
  message: "How do I paginate the list endpoint?",
});

for await (const event of stream) {
  if (event.type === "token") render(event.text);
  if (event.type === "citations") showSources(event.citations);
}

Frequently Asked Questions

Common questions about API & SDKs

Public client keys (bq_pk_…) are safe to ship in browsers and mobile apps; client ID + secret pairs (bq_ci_…/bq_cs_…) are for backend integrations. Keys are created per knowledge base and revocable from the dashboard.
Yes. Chat endpoints stream over server-sent events, delivering tokens as they generate plus a structured citations payload — the widget and SDKs use the same streams.
Yes. Keys are scoped to a knowledge base, and allowed source groups can narrow retrieval further — for example, a partner-facing key that only sees that partner's product docs. Scoping can narrow access, never widen it.
Yes. @beforequery/agents lets you define agent graphs (coordinator → specialists), run them against the agents API, and includes MCP and A2A clients for interop with the broader agent ecosystem.
The core SDK is framework-agnostic TypeScript that runs in browsers, React Native, and Node. The React package adds a drop-in component and headless hook; everything else can hit the HTTP API directly.

Start building on the API

Grab a client key and stream your first cited answer in minutes.

Get Started Free