Skip to main content
The Gloo Grounded Completions API extends the Completions V2 architecture with Retrieval-Augmented Generation (RAG), combining intelligent routing with powerful source-grounded response capabilities. Ground your AI responses in your own content—upload datasets, point the API at your publisher, and every response will be backed by your specific sources.
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.
When you need responses backed by specific content rather than pure model knowledge, grounded completions retrieve relevant context from your uploaded datasets and provide it to the model during generation. Set the 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. The sources_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 the rag_publisher parameter to your publisher name to ground responses in your uploaded content:
The model will only retrieve and reference content from your specified publisher. To find your publisher name, navigate to the Publishers page in Studio.
You must have already uploaded content before using grounded completions with your publisher.
If you omit the 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 the sources_limit parameter (1-10, default is 3):
More sources provide broader context but increase processing time. Choose based on your use case—3 sources work well for most queries, while complex theological questions may benefit from more.

Include Citations

Include citation metadata for sources utilized by RAG (defaults to false)
For streaming responses, citations will be pre-pended to the response in the following format:

Tradition-Based Personalization

Customize responses to align with specific theological perspectives using the tradition parameter:
Supported traditions:
  • "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 explicit model and cannot be combined with auto_routing or model_family.
When specified, both the RAG retrieval and response generation adapt to the theological tradition, ensuring appropriate language, concepts, and emphases.

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 requests library (pip install requests). The TypeScript example uses the built-in fetch (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

When stream: 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:
The event stream follows standard Server-Sent Events format. For detailed streaming implementation guidance, see the Completions V2 streaming documentation.

Response Metadata Fields