search.deep runs an agent over a workspace and returns a Promise<Job>.
The agent picks its own tools, authors evidence, and can take minutes. Files
must already be ingested.
There is no tier argument. Deep search uses a consistent reasoning engine with medium thinking budget. Filtered search is not wrapped in the TypeScript SDK.
Basic usage
Method signature
Parameters
Returns
AJob whose result has result_type deep_search_v2, scoped or not, first
turn or follow-up. Deep-search jobs created before September 2026 may still
read back as intelligent_search.
There is no exported isDeepSearchV2Result helper. Narrow with result_type
and !(result instanceof UnknownResult).
Scope files
Omit bothpaths and path_prefix for a corpus-wide, source-level run.
Pass paths to pin every tool to those files (unknown or inaccessible paths
are refused before a job is created; there is no limit on how many). Combined
with path_prefix, the two add up: the run covers every uploaded file under the
folder plus every named file. The run resolves them into one set of uploaded
files, and every tool — search, listings, reads, SQL, the shell — sees only that
set. A path_prefix alone scopes to every uploaded file under that folder; to
narrow a folder to some of its files, send only paths.
Follow-up threads
Pass the previous result’ssession_id. Only the API key that started the
thread may continue it. A thread whose turn is still running returns 409
session_busy. A thread started before September 2026 cannot be continued:
the follow-up returns 404 session_not_found, so start a new thread.
Do not reuse one session across unrelated questions.
Clarifications
Withallow_clarification: true, a genuinely ambiguous query can finish with
clarification set, answer null, and empty evidences. Reply on the same
session_id.
Context and surface
context is caller-supplied background, not a hidden system prompt replacement.
surface only groups console history (qa, workbook). Omit it from SDK
integrations. Follow-ups inherit the thread head.
Structured answers
Passoutput_schema (a JSON Schema object) to get the answer as JSON instead of
prose. The root must be an object; wrap a list as { items: [...] }. $ref may
only point inside the schema, and not back at itself. pattern and
patternProperties are refused; state a format in description instead.
unevaluatedProperties / unevaluatedItems are refused; use
additionalProperties / items.
The agent is told the schema and its answer is checked against it; a miss is
sent back for correction. On success answer is the JSON text and
structured_answer is the parsed value. A field the source does not state comes back null, whatever type the schema gives it.
If the answer still misses after the
corrections, the job still succeeds with structured_answer set to null.
Check structured_answer, not answer.
Result structure
exhausted: true means the step budget ran out. The job still succeeded; the
answer may rest on less evidence. That is not JobFailedError.
deep_search_v2
Search does not wait for quote locations. After the result, poll every id in
grounding_job_ids. An empty list means no automatic Ground jobs were planned;
deployments may disable them for API searches. A missing field identifies an
older result. When empty or absent, call client.documents.ground explicitly
if you need quote locations.
Complete example
Error handling
Best practices
Ingest first
Search reads derived representations. Upload plus ingest, then ask.
One question per turn
Start a new session for a new investigation. Follow-ups belong on that
turn’s
session_id.Read exhaustion
exhausted: true is a successful, budget-capped answer — not a failed job.Related search methods
See Search methods and the Search guide.
Next steps
Workspaces
Create a corpus, upload, and ingest before searching.
Job management
Wait, stream events, and cancel long-running jobs.
Journal-entry testing
Test a ledger package and read the SQL behind each figure.