Search Tutorial
Introduction
This tutorial covers the GroundX search API.
To have an agent search and answer for you, see Use GroundX With Your Agent.
The Search API:
-
Analyzes your query, rewrites it when needed and runs a semantic search.
-
Searches your buckets and returns text chunks with metadata, document and section summaries, source URLs and text prepared for LLMs.
-
Reranks chunks by how well they answer the original query.
-
Combines the results into a text block you can pass to an LLM as context.
Getting more results
Use the search.nextToken from your last response as nextToken to get the next page.
GroundX usually keeps results for 30 seconds. More pages from those results are
free, even if you’ve reached your search limit. Once the results expire, GroundX
runs the search again and counts it as a new search. Sending a query without
nextToken also counts as a new search.
LLM Integration
To use search results in an LLM response:
- Make an API search request.
Example:
- Go to the GroundX dashboard to get your API key.
- Install the Python SDK with pip install groundx
- Install the TypeScript SDK with npm i -s groundx
- Pass
search.textto your LLM.
Example:
Get an API key, endpoints and SDK from your LLM provider. For OpenAI, see the OpenAI documentation.
- Read the LLM response.
Example:
The LLM uses retrieved document content as context for its response.
Getting Started
The examples above use placeholder values. The following sections explain each search parameter.
Before searching:
Ingest content
Ingest your content into a GroundX bucket and wait for processing to complete. See the ingest documentation for upload steps.
Set up environment
Set up your environment with the GroundX SDK.
Bucket or Group ID
Get the ID of the group or bucket you want to search.
Example:
See the ingest documentation for bucket creation steps.
Search Query String
Set query to a question or search keywords.
If the string is more than 30 words long, GroundX automatically rewrites it with keywords using its internal LLM.
GroundX matches the query against your content and search metadata.
Example:
Number of Results
Set n to limit the number of results. The default is up to 20.
Example:
API Request
Call search with the bucket or group ID and your query.
Search also accepts these optional parameters:
For search rate limits (concurrent requests, requests per minute) and error-handling guidance, see the Direct SDK/API Quickstart’s Errors and Rate Limits section.
Example:
API Response
The request returns a Search object:
Response sample:
Recommended data
Pass search.text to your LLM. It contains rewritten text chunks and search metadata, prepared by GroundX’s internal LLM with document context.
Advanced data handling
Use search.results when your application needs to handle individual results.
results contains matching text chunks, ordered by semantic search and reranking score. Each result includes the original text and a rewritten suggestedText version.
Results can include generated searchData, such as document and section summaries. As of SDK 3.5.4, summaries are also available in top-level fileSummary and sectionSummary fields. Use these when you need only summary text. The corresponding searchData fields are documentSummary and sectionSummary.
Each result includes the source URL, document ID and bucket ID.
Each result has a unique chunkId. Visual elements, such as tables or charts, can include a multimodalUrl for the cropped image. Use boundingBoxes to locate a chunk on its source pages. The pages field provides rendered page images and the pixel dimensions used by those coordinates.
Use verbosity (see API Request above) to control whether results is returned at all,
and whether each result includes the full searchData object.
Final Details
Use the retrieved content as context for your LLM’s answers.
Next Steps
- For tips on turning search results into consistent, high-quality LLM responses, see Prompting and Integration.
- To have an agent search and answer for you, see Use GroundX With Your Agent.
Expiring source links
Protected search results may contain storage-signed source, page and crop links that expire. Keep document, chunk and page identifiers separately from their URLs. When a link expires, repeat an authorized search or request a new file-link for the owned file. For document review, fetch the authenticated X-Ray ?view=links URL again. Stable protected URLs require server-side owner authentication on every read. See File Access and Sharing.

