seltz
v2.3.0
Published
Official TypeScript SDK for Seltz
Readme
Seltz TypeScript SDK
Official TypeScript SDK for Seltz, the Web search engine for AI agents.
💾 Installation
npm install seltzRequires Node.js 18.0 or higher.
⚡️ Quick Start
import { Seltz } from "seltz";
const client = new Seltz({ apiKey: "your-api-key" });
// Search the Web
const result = await client.search({ query: "best ai search engines", maxResults: 10 });
// Access results
for (const doc of result.documents) {
console.log(doc.url);
console.log(doc.content);
}Output:
URL: https://www.best-ai-search-engines.com
Content: Generative AI can make finding information faster and more intuitive.
If you’re tired of traditional search, explore some of the best AI-powered
search engines we've tested...Answer
Get a natural-language answer grounded in Web search results, with citations:
import { Seltz } from "seltz";
const client = new Seltz({ apiKey: "your-api-key" });
const result = await client.answer({ query: "Who is Apple's next CEO?" });
console.log(result.answer);
for (const citation of result.citations) {
console.log(citation.url);
}Streaming
Stream the answer as it is generated. The first event carries the citations, followed by incremental text chunks, and a final finish reason:
import { Seltz } from "seltz";
const client = new Seltz({ apiKey: "your-api-key" });
for await (const event of client.answerStream({ query: "Who is Apple's next CEO?" })) {
switch (event.event.case) {
case "citations":
for (const citation of event.event.value.citations) {
console.log(citation.url);
}
break;
case "textDelta":
process.stdout.write(event.event.value);
break;
case "finishReason":
console.log(`\n[done: ${event.event.value}]`);
break;
}
}📚 Documentation
Browse the documentation for more details.
