Prompting and Integration
Introduction
GroundX parses, stores, and retrieves information from complex documents for LLM applications. This guide shows how to pass retrieved information to an LLM in question answering, conversations, and agent workflows.
Each pattern calls the GroundX API once per user query, or more often in an agent loop. Handle rate limits in your calling code. See Errors and Rate Limits in the Direct SDK/API Quickstart.
Use Case 1) Traditional RAG
For question answering, retrieval augmented generation (RAG) combines the user’s question with information retrieved from documents. Send the query to GroundX, then build a prompt with:
- A system prompt that explains the task and how to use the retrieved information.
- The retrieved information relevant to the query.
- The user’s query.
Answer quality depends on accurate, readable source information and clear instructions. Adapt the system prompt to your application. The following example provides a starting point:
Writing Effective Prompts
These guidelines apply to RAG system prompts and GroundX workflow prompts, including search-query rewrites, document processing, and additionalContext.
State the task, trusted inputs, output format, and response to missing evidence. Use plain English and remove instructions that do not change the model’s behavior.
Avoid:
- Long introductions about the workflow, agent, model, or implementation.
- Labels and headers that sound precise but don’t say what to do.
- Broad synonym bags instead of the source’s exact words.
- Repeating the same instruction three times in different words.
- Asking for evidence, then allowing unsupported guesses anyway.
Before using a prompt in production, check that its task and output format are clear. Specify how to handle missing evidence, usually with null or omission.
The example above describes the assistant’s role at length. For new prompts, state the task, output format, and evidence rules directly.
Use result.search.text from the search.content response as the RAG context.
Pass the system prompt, GroundX context, and user query to the LLM. These examples use OpenAI message objects:
Use Case 2) Conversational RAG
For conversational RAG, decide how much retrieved information to keep in the conversation:
- Keep retrievals from every query. This can help with detailed questions that connect earlier topics, but uses more context space and increases LLM costs. A more complex conversation can also increase hallucination risk.
- Keep the user queries and LLM responses, but include GroundX context only for the latest query. The model retains the conversation history and receives source information for the current question.
Start with context for the latest query, then adjust based on testing. This is usually sufficient and costs less.
Use case 3) Agentic RAG
GroundX retrieves document information relevant to a query. Some requests may need several retrievals:
- Exhaustive summaries that must include details a relevance search might omit.
- Compound questions that require several smaller questions to be answered first.
Traditional RAG can still work for these requests. For complex questions or datasets, an agent can use GroundX as a tool and make multiple queries.
Implementation depends on your agent framework. To expose GroundX as a tool:
- Create a function that accepts a text query, calls search.content, and returns
result.search.text. - Describe the tool so the agent knows when to use it. For example, describe GroundX as a retrieval engine that returns document information relevant to a question.
Tool descriptions affect when the agent searches and which queries it sends. Test them alongside the descriptions of your other tools. Start with traditional RAG and add an agent when the task requires the extra complexity.
GroundX Agent Harness provides Claude, Codex, or another agent with GroundX instructions and, where supported, authenticated access through hosted Model Context Protocol (MCP) tools. See What Is GroundX Agent Harness? to get started.

