Grounded completions (RAG) and intelligent routing are Completions V2 features. For general, OpenAI-compatible model access — including guardrails and
tradition — the Responses API is the recommended surface for new integrations; RAG grounding in the Responses format is available via Grounded Responses.rag_publisher parameter to your publisher name and the API handles retrieval, grounding, and attribution automatically.
Like Completions V2, you get the same three routing options—auto-routing, model family selection, or direct model choice—plus tradition-based personalization and input guardrails, all while ensuring responses remain grounded in retrievable sources.
Why Grounded Completions?
Grounded completions solve the core challenge of AI trustworthiness: verifying what the model tells you. Here’s what you get: Reduced Hallucinations By grounding responses in actual content from your specified dataset rather than relying solely on model training, you significantly reduce fabricated or incorrect information. The model generates answers based on retrieved content it can reference. Content-Grounded Responses Every response is informed by relevant sources retrieved from your uploaded content. Thesources_returned flag in the response confirms that RAG was used to ground the generation.
Publisher-Scoped Knowledge
Query your own uploaded content, ensuring responses draw from approved, relevant sources rather than generic web knowledge. Control exactly what knowledge base powers your AI.
Routing Flexibility
Keep all the intelligent routing capabilities from Completions V2—let Gloo choose the best model automatically, select by provider family, or pick a specific model for your use case.
Grounding reduces fabrication; it does not verify that a given sentence appears in the retrieved sources. If your application serves quotations, titles, or attributions, check the answer against its sources before display. See Building Trustworthy Grounded Applications.
Key Features
RAG Configuration
Using Your Own Content
Set therag_publisher parameter to your publisher name to ground responses in your uploaded content:
You must have already uploaded content before
using grounded completions with your publisher.
rag_publisher parameter, the API falls back to GlooGrounded, a shared dataset assembled by Gloo. For best results, we recommend always specifying your own publisher.
Source Limits
Control how many sources are retrieved and considered with thesources_limit parameter (1-10, default is 3):
Include Citations
Include citation metadata for sources utilized by RAG (defaults to false)Tradition-Based Personalization
Customize responses to align with specific theological perspectives using thetradition parameter:
"evangelical"- Evangelical Protestant perspective"catholic"- Roman Catholic perspective"mainline"- Mainline Protestant perspective"not_faith_specific"- Neutral, non-faith-specific perspective (uses Gloo’s non-faith-specific prompt rather than a Christian tradition). Requires an explicitmodeland cannot be combined withauto_routingormodel_family.
Code Examples
The grounded endpoint is a distinct path (
/ai/v2/chat/completions/grounded), not a model ID. The OpenAI SDK always posts to {base_url}/chat/completions, so it cannot reach the grounded path. Use a direct HTTP request instead, as shown below.Prerequisites
Before starting, ensure you have:- A Gloo AI Studio account
- Your API key from the API Credentials page
- Authentication setup - Complete the Authentication Tutorial first
- For the Python example: the
requestslibrary (pip install requests). The TypeScript example uses the built-infetch(Node 18+).
Endpoint Details
URL:https://platform.ai.gloo.com/ai/v2/chat/completions/grounded
Operation: POST
Example cURL Request
Request Parameters
Exactly one routing mechanism must be specified:
auto_routing: true,
model, or model_family.For Anthropic models, add the
X-Cache-TTL header to enable explicit caching. OpenAI and DeepSeek models use implicit caching automatically. For OpenAI, you can optionally add prompt_cache_key to improve hit rates. See the Prompt Caching Guide for details.Response Format
Non-Streaming Response
Streaming Response
Whenstream: true, responses are sent as Server-Sent Events. Routing and RAG metadata is provided in HTTP headers:
When
include_citations: true is set in the request and sources are found, a citations event is emitted as the first SSE chunk before any LLM content, with the shape:
Response Metadata Fields
Related Documentation
- Building Trustworthy Grounded Applications - Verifying answers against sources, prompt contracts, multi-turn handling, and evaluation
- Grounded Responses - The same RAG grounding in the Responses API (v1) format
- Completions V2 API - Core routing mechanisms and streaming details
- Search API - Standalone RAG queries without generation
- Tool Use Guide - Using function calling with grounded completions
- Supported Models - Model capabilities and context windows

