Initialization
Configuration Options
Methods
search
client.search runs a search query and returns the matching documents.
search method accepts a single SearchParams object:
Returns:
Promise<SearchResponse>
Filter examples:
answer
Preview.
/answer is grounded in the web scope by default, which is in beta. Pass scope to ground elsewhere — for example, news for current-events questions.client.answer generates a direct, natural-language answer to a question, grounded in live web search results, with citations to the sources used.
answer method accepts a single AnswerParams object:
Returns:
Promise<AnswerResponse>
Answer tiers:
An omitted or unrecognized
model falls back to seltz-base; the response shape is unchanged.
responseFormat — an OpenAI-style object — to get structured output. result.answer then carries a JSON string matching your schema instead of Markdown, and inline citations no longer appear in the answer text; result.citations is returned either way. A malformed responseFormat is rejected before the request is billed, raised as SeltzAPIError.
systemPrompt to steer how the answer is presented — tone, voice, format.
answerStream
client.answerStream streams an answer as the model generates it, instead of waiting for the whole thing. It accepts an AnswerStreamParams object with the same fields as answer. Requires seltz v2.3.0 or later.
The stream yields AnswerStreamResponse events, and each event holds exactly one member in event.event. Switch on event.event.case: the first event is "citations", the next events are "textDelta" chunks of the answer, and the final event is "finishReason".
AsyncIterable<AnswerStreamResponse>
Calling A stream also has no per-call deadline.
answerStream doesn’t send the request. The request goes out when you start iterating, so errors are thrown inside the for await loop, not at the call. Wrap the whole loop in your try:answer gives up after 30 seconds, but answerStream keeps going until the answer finishes.fetch
client.fetch retrieves the content of up to 20 URLs you already have and returns each page as Markdown. Requires seltz v2.9.0 or later.
status set to FetchStatus.ERROR and an error.code, so check each result before you read it.
Returns: Promise<FetchResponse>, with one FetchResult per requested URL.
The fetch method accepts a single FetchParams object. See the Fetch reference for its fields (urls, formats, tier, timeoutMs), the result fields, and the per-URL error codes.
agent
client.agent runs multi-step research over the web and returns a cited report. Requires seltz v2.9.0 or later.
Runs are asynchronous. create returns the run in pending state, and createAndWait starts a run and resolves once it reaches a terminal state.
create, get, list, cancel, wait, and createAndWait. See SDK methods for what each returns.
Check run.status and run.stopReason before you rely on the output: a run can end failed. See the Agent reference for the request fields, the run envelope, and what each status and stop reason means.
monitor
client.monitor manages monitors, which run a set of saved searches on a schedule and deliver each new document once. Requires seltz v2.7.0 or later.
create, get, list, update, delete, listRuns, getRun, listRunRequests, listRecords, listRunRecords, and streamRecords. Each returns the whole response message, so read response.monitor rather than expecting the monitor itself. See SDK methods for what each returns, the rest of the Monitor reference for paging, cadence, limits, and errors, and Webhooks to be told when a run finishes.
Response Types
SearchResponse
AnswerResponse
AnswerStreamResponse
One event fromanswerStream. Each event sets exactly one member of event.
Error Types
All errors extendSeltzError.
This example constructs the client outside the
try, so a missing SELTZ_API_KEY throws SeltzConfigurationError at startup rather than per query. The handler covers only the errors search() can throw.
TypeScript Types
Import types directly from the package. These are the ones you use most:type when you compare against them: