>=20 and works in Bun, Deno, and edge runtimes — environment variables are read through a guard, so runtimes without process simply behave as anonymous/default.
Configuration
| Option | Environment variable | Default |
|---|---|---|
apiKey | CAESAR_API_KEY | anonymous (lower rate limit) |
baseUrl | CAESAR_BASE_URL | https://search-api-staging-779189860552.europe-west1.run.app |
maxRetries | — | 3 — retries 429/5xx, honors Retry-After; 0 disables |
timeoutMs | — | 30000 — per-request timeout in milliseconds |
Methods
How read() resolves its target
The first positionaltarget is auto-detected: a UUID-shaped string is sent as doc_id, anything else as canonical_url. Explicit docId/url options win if both are given. If neither resolves, the SDK throws TypeError("provide a docId or a url"). Default include is ["metadata", "content"]; passing a query selects query-relevant content, otherwise the full document, always as markdown. See documents for the response shape.
Continuation reads
Whendoc.content?.truncated is true, resume from where the last read ended:
startChar forces full-document selection and addresses raw document text, so offsets stay contiguous between calls — it will not combine with query-relevant selection.
Response shaping
verbosity and maxCharsTotal map onto the wire response block — see response shaping.
Errors and retries
All error classes are importable from the package root:.code comes from the API error envelope (error.code), falling back to http_<status>; .requestId carries the server’s request_id.
Retry semantics: statuses 429, 500, 502, 503, and 504 are retried up to maxRetries times (default 3 retries, so up to 4 attempts) with exponential backoff of 0.5s doubling per attempt, capped at 8 seconds. A Retry-After header is honored when it is a numeric number of seconds (also capped at 8s). Timeouts and connection failures are not retried — they throw APITimeoutError / APIConnectionError immediately. Each attempt gets its own timeoutMs abort signal.
Raw responses and extra fields
caesar.withResponse.search(...) (also .read, .feedback) takes the same arguments and returns { data, response }, where response is the fetch Response — useful for reading rate-limit headers or status. For request fields the options don’t model yet, pass extraBody; it is merged last and can override any field.
All generated request and response types (SearchResponse, DocumentResponse, FeedbackResponse, SearchRequest, FeedbackRequest, and more) are re-exported from the package root.
For agents
timeoutMsis milliseconds (30000= 30s). The Python SDK usestimeoutin seconds — do not transplant values between them.- Response collections and nested objects are typed as optional. Guard with
??and?.exactly as the quickstart does (results.results ?? [],doc.content?.text). - Request options are camelCase (
maxResults,sessionId,docId); response fields are snake_case as the API returns them (search_id,doc_id,canonical_url,start_char,char_count). Mixing the two directions is the most common bug.