search.deep runs an agent over a workspace and returns a 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.
Basic usage
Method signature
Parameters
Returns
AJob whose job.result is a DeepSearchV2Result (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 IntelligentSearchResult
(intelligent_search).
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. Filtered search has no session; deep search does.
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 to get the answer as JSON instead of prose. It takes a
JSON Schema dict or a Pydantic model class. 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 to the agent 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 None, whatever type the schema gives
it, so declare such fields optional in a Pydantic model you validate into.
If the answer still misses the schema
after the corrections, the job still succeeds: answer holds what the agent
wrote and structured_answer is None. 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.
DeepSearchV2Result
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
Async client
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.