Node.js / TypeScript SDK
`brime` — TypeScript-first, dual ESM+CJS, native fetch.
Works on Node 18+, Bun, Deno, Cloudflare Workers, and modern browsers (native fetch + ReadableStream). Zero external HTTP dependencies. Ships ESM + CJS + .d.ts.
npm install @brime-ai/brimeQuickstart
import { Brime } from "@brime-ai/brime";
const client = new Brime({ apiKey: "sk-brime-..." });
const result = await client.search({ query: "Tesla Cybertruck recall 2025" });
console.log(result.answer);new Brime() with no arg picks up BRIME_API_KEY from the environment.
API
Search
await client.search({
query: "tesla earnings",
topic: "finance",
time_range: "week",
max_results: 10,
});Single tuned instant tier. The historical depth option is still accepted for backward compat but ignored by the gateway.
Extract
await client.extract({ urls: ["https://example.com"] });
// or override the auto Idempotency-Key:
await client.extract(
{ urls: ["https://x"] },
{ idempotencyKey: "stable-2026-05-06" },
);Research
const r = await client.research({ query: "latest GPT-5 release notes" });
// ^ ResearchBasicResponse (single tuned multi-round flow, ~30–90 s)The historical depth, max_rounds, wait options are still accepted for backward compat but ignored.
Streaming research
for await (const evt of client.researchStream({ query: "latest GPT-5 release notes" })) {
console.log(evt.event, evt.data);
if (evt.event === "complete" || evt.event === "error" || evt.event === "timeout") {
break;
}
}break-ing out of the loop cancels the underlying HTTP stream cleanly — no resource leaks.
Errors
import { Brime, BrimeError, AuthenticationError, RateLimitError } from "@brime-ai/brime";
try {
await client.search({ query: "..." });
} catch (e) {
if (e instanceof AuthenticationError) console.error("Bad key");
else if (e instanceof RateLimitError) console.error("Slow down");
else if (e instanceof BrimeError) console.error(`${e.code} (HTTP ${e.status})`);
else throw e;
}instanceof checks work across ESM and CJS boundaries (we preserve the prototype chain).
TypeScript types
Every request and response is fully typed. Import the types you need:
import type {
SearchResponse,
ExtractResponse,
ResearchBasicResponse,
ResearchDeepInitResponse,
ResearchStatusResponse,
ResearchSseEvent,
} from "@brime-ai/brime";Configuration reference
| Constructor option | Env var | Default |
|---|---|---|
apiKey | BRIME_API_KEY | — (required) |
baseUrl | BRIME_BASE_URL | https://api.brime.dev |
timeout | — | 30_000 ms |