CAESAR_API_KEY before running the quickstart:
>=20 and works in Bun, Deno, and edge runtimes — environment variables are read through a guard, so runtimes without process should pass apiKey explicitly.
Configuration
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"]; content selection is full_document; content format is markdown; maxChars is omitted unless you pass it. 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.
Uploading files
uploadFile() collapses the presign → upload → index flow into one call. data accepts a Blob, ArrayBuffer, Uint8Array, or string (UTF-8 encoded):
index: false, then call indexFiles() once. See Files for supported types, limits, and the workspace search scope.
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. Caesar rate limits use X-RateLimit-Reset; if a numeric Retry-After header is present, the client honors it, 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.