> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge bases via AI Gateway

> Integrate knowledge bases through the AI Gateway. Enable RAG retrieval in LLM calls with automatic context injection for enhanced AI responses.

**Use Cases**

* Grounding responses in proprietary documents without fine-tuning.
* Internal Q\&A bots over company handbooks, policies, or codebases.
* Adding domain-specific knowledge to a general model without prompt stuffing.
* Reducing hallucinations by giving the model access to authoritative sources at query time.

***

## Prerequisites

Knowledge Bases are made to provide relevant and specific information for an LLM to use. To get started, see Creating a Knowledge Base, Knowledge Bases need to be enriched with the source documents and configured to expose chunks fitting the use case.

> [!NOTE]
>
> Use the Knowledge Base `id` as `knowledge_id` in the model generation.

> [!NOTE]
>
> The `knowledge_bases` field is available on the Chat Completions endpoint (`/v3/router/chat/completions`) only, via the `orq` extension object. It is not supported on the Responses API (`/v3/router/responses`).

## Quick Start

Using the created Knowledge Base, and its `id`, include the `knowledge_bases` payload within the model generation call.

> The knowledge\_bases payload contains query configuration and search type, to learn more, see Search Modes and Chunking Strategy.

```bash cURL (Chat Completions) theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST https://router.toqan.ai/eu/v3/router/chat/completions \
  -H "Authorization: Bearer $TOQAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5.6-sol",
    "messages": [{"role": "user", "content": "How can I upgrade my account?"}],
    "orq": {
      "knowledge_bases": [
        {
          "knowledge_id": "api-documentation",
          "top_k": 5,
          "threshold": 0.7,
          "search_type": "hybrid_search"
        }
      ]
    }
  }'
```

```typescript TypeScript (Chat Completions) theme={"theme":{"light":"github-light","dark":"github-dark"}}
import OpenAI from "openai";

const openai = new OpenAI({
  apiKey: process.env.TOQAN_API_KEY,
  baseURL: "https://router.toqan.ai/eu/v3/router",
});

const response = await openai.chat.completions.create({
  model: "openai/gpt-5.6-sol",
  messages: [{ role: "user", content: "How can I upgrade my account?" }],
  orq: {
    knowledge_bases: [
      {
        knowledge_id: "api-documentation",
        top_k: 5,
        threshold: 0.7,
        search_type: "hybrid_search",
      },
    ],
  },
});
```

```python Python (Chat Completions) theme={"theme":{"light":"github-light","dark":"github-dark"}}
from openai import OpenAI
import os

client = OpenAI(
    api_key=os.environ.get("TOQAN_API_KEY"),
    base_url="https://router.toqan.ai/eu/v3/router",
)

response = client.chat.completions.create(
    model="openai/gpt-5.6-sol",
    messages=[{"role": "user", "content": "How can I upgrade my account?"}],
    extra_body={
        "orq": {
            "knowledge_bases": [
                {
                    "knowledge_id": "api-documentation",
                    "top_k": 5,
                    "threshold": 0.7,
                    "search_type": "hybrid_search",
                }
            ]
        }
    },
)
```

> [!TIP]
>
> **Toqan Router** will automatically enrich the model generation with the given context and query to the knowledge base

Knowledge Base


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.