For the complete documentation index, see llms.txt. This page is also available as Markdown.
TypeScript
Install
cURL
npm install scispaceRequires Node 18 or later. Ships ESM and CJS builds with bundled type declarations.
Configure
TypeScript
import Scispace from "scispace";
const client = new Scispace({
apiKey: process.env.SCISPACE_API_KEY, // the default
timeoutMs: 60_000,
maxRetries: 4,
apiVersion: "2026-08-01",
});Minimal example
TypeScript
const search = await client.searches
.create({ query: "How does climate change affect biodiversity?", depth: "standard" })
.wait();
console.log(search.answer.text);Ergonomics
Auto-pagination
TypeScript
for await (const paper of client.papers.list({ query: "transformer architecture" })) {
console.log(paper.doi);
}Streaming
TypeScript
const stream = client.chats.messages.stream({
chatId: "chat_1r8eaidwoq",
content: "What datasets were used?",
});
for await (const event of stream) {
if (event.type === "message.delta") process.stdout.write(event.delta);
if (event.type === "citation.added") console.log(`\n[${event.citation.index}]`);
}
const message = await stream.finalMessage();Types
depth, status, and error.type are union types, not string. Response types are exported:
TypeScript
import type { Search, Citation, Paper } from "scispace";Errors
TypeScript
import { InvalidRequestError, RateLimitError, InsufficientCreditsError } from "scispace";
try {
await client.searches.create({ query: "" });
} catch (e) {
if (e instanceof InvalidRequestError) console.error(e.code, e.param, e.requestId);
}Edge and browser
The SDK runs in any Fetch-capable runtime, including edge functions.
Never ship a key to a browser
There is no browser-safe key. Call the API from your server and proxy the result. See authentication.
Full reference
Generated API surface: https://docs.scispace.com/sdks/typescript/reference.
Related
Last updated