documents.ground finds supplied text in a document and returns source
locations. Use it to connect a value or quote back to evidence.
Basic usage
Method signature
Parameters
Returns
AJob. After success, job.result is a GroundResult:
Define targets
Every target needs an ID and the text to locate:id, not
by quoted text.
Disambiguate repeated text
Add nearby context withhint:
hint is used for PDF,
image, text and HTML sources; for spreadsheet and CSV sources only sheet is
used.
Match by meaning
Withsemantic: true, text describes what to find instead of quoting it,
for example "net revenue for FY2023". On deployments that ground PDF, Word and
PowerPoint sources with the exact-match runtime, the answering sentences, table
cells, lines, blocks, sections (a heading with its text) or table rows come back
best first, up to max_matches, each with match_method: "semantic". hint
steers the pick. A target whose answer is not in the source comes back not
found. If the picking model is unavailable, the target fails with error
native_2_semantic_unavailable.
Select a worksheet
Usesheet to narrow a workbook target to one tab:
sheet is ignored for non-spreadsheet sources.
Configure matching
minimum_semantic_score does not affect exact or normalized matches.
require_visual_region exists in the model but is not supported by the
current runtime; do not enable it.
Response structure
Each target has an independent outcome:not_found is a successful answer about the document; the job itself remains
succeeded. failed means that target encountered an error.
Matches are sorted best-first:
Location types
The location model follows the source:Ground response format
Review target status, ranking, match methods, locator fields, and related artifacts.
Preview visual matches
jobs.groundCrop to fetch the bytes through the SDK:
Reuse a parse
Complete example
Error handling
not_found and failed statuses.
Common request errors include an empty target list, more than 30 targets, an
unsupported option, or a source the current grounding path cannot read.
Best practices
Use exact source text
Quote the text as written when you have it. Set
semantic to describe what to find when you do not.Add nearby context
Use
hint to rank the intended occurrence when a quote repeats.Join on target ID
Treat the caller-defined ID as the stable key between request and response.
Handle not_found
A missing quote is a successful document-level answer, not an exception.