API & SDKS
Build any answer experience on our pipeline
Everything the widget does is available to your code: streaming grounded chat, hybrid search, feedback, suggested questions, and agents — via a public API and typed SDKs for web, React, React Native, and Node.
Capabilities
The developer surface
Same pipeline as the widget, full control of the experience
01
Client-key authenticated
Public API
- SSE streaming chat with the source shown
- Hybrid search with ranked, scored results
- Suggested questions and related articles
- Form deflection with confidence scores
- Feedback and threaded conversations
02
Typed, small, focused
SDKs
- @beforequery/sdk — browser, React Native, Node
- @beforequery/react — component + headless hook
- @beforequery/widget — embeddable Ask AI launcher
- Public keys for client-side, ID + secret for servers
03
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 source-attribution.
- 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
@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);
}What teams say
Deployed in production.
“Deployed on our docs site in an afternoon. Every answer shows the source, and the abstention gate means we've never had a customer complain about a made-up answer.”
Priya Nair
Head of Customer Support · Supabase
“The knowledge base connected to our Slack, Confluence, and helpdesk in one setup. On-call teams get the same grounded answer whether they ask in chat, in the widget, or from Cursor.”
Tom Richter
IT Operations Manager · Grafana Labs
“The gap analytics turned into a real docs backlog. Deflection went up because we finally knew which pages were missing — the AI told us.”
Ana Castillo
VP of Customer Experience · Clerk
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 sources 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. The REST and SSE APIs are open, and every knowledge base exposes an MCP server and an A2A endpoint for interop with the broader AI 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 grounded answer in minutes.
Get Started Free