Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.orq.ai/llms.txt

Use this file to discover all available pages before exploring further.

Orq.ai provides three approaches to backing an agent with persistent knowledge:

Knowledge Bases

Upload and index documents for retrieval-augmented generation. Ground model responses in your domain data.

External Knowledge Bases

Connect your own vector database via a standard API. Keep data management on your infrastructure.

Memory Stores

Entity-scoped long-term memory that persists across sessions. Enables personalization and context continuity.
All three can be attached to an Agent to build richer, context-aware experiences:

Connect Knowledge Bases to Agents

Attach a Knowledge Base so the agent queries it automatically when relevant.

Connect Memory Stores to Agents

Give the agent persistent per-entity memory across conversations.

Use-cases

All three solutions store information that an agent can retrieve, but they serve different purposes depending on where the data lives and how it changes. Knowledge Bases index documents you upload into Orq.ai. The platform handles embeddings, chunking, and retrieval. Use them when you have documents to ingest and want a fully managed RAG pipeline. External Knowledge Bases connect to a vector database you already operate. Orq.ai calls your API at query time and passes the results to the model. Use them when your data cannot leave your infrastructure, or when you already have an embedding pipeline. Memory Stores store arbitrary text per entity, such as a user or session. Documents accumulate over time and are retrieved semantically on each interaction. Use them when your agent needs to remember what a specific person said or did in a previous conversation.
Knowledge BaseExternal Knowledge BaseMemory Store
Data hosted byOrq.aiYour infrastructureOrq.ai
Document uploadVia Studio or APIManaged externallyVia API per entity
EmbeddingsManaged by Orq.aiManaged externallyManaged by Orq.ai
Search configFull controlDelegated to your APIAutomatic
RerankingSupportedPost-processingNot applicable
Agentic RAGSupportedSupportedNot applicable
Metadata filteringFull supportDepends on your APIVia entity metadata
Scoped per entityNoNoYes
Persists across sessionsYes (static content)Yes (static content)Yes (accumulates over time)
Best forDomain documents, FAQs, policiesExisting vector DBsUser history, preferences, session state

Knowledge Bases

A Knowledge Base is a database that provides relevant, specific information for an LLM to retrieve at query time. Knowledge can include domain-specific or business-specific information, ensuring the details surfaced to models are both correct and accurate.

Create a Knowledge Base

Use the + button in a chosen Project and select Knowledge Base > Internal.Press Create Knowledge. The following modal appears:
You can only create a Knowledge Base once you have activated an embedding model within the AI Router.

Datasource and Chunking

A source represents a document loaded within the Knowledge Base. Documents are parsed and split into chunks that models search and retrieve at query time.

Create a Datasource

Select Add Source to upload a document. Supported formats: TXT, PDF, DOCX, CSV, XML.
A single source document must be a maximum of 10MB.
Once your document has been processed, the following summary is displayed:

Add Chunks to a Datasource

Use the Create chunk API to manually add chunks to a datasource.
curl --request POST \
   --url https://api.orq.ai/v2/knowledge/<knowledge_id>/datasources/<datasource_id>/chunks \
   --header 'accept: application/json' \
   --header 'authorization: Bearer <API_KEY>' \
   --header 'content-type: application/json' \
   --data '
[
  {
    "text": "Your chunk content here.",
    "metadata": {
      "source": "manual",
      "topic": "example"
    }
  }
]
'

View Datasource Chunks

Use the List all chunks API to inspect chunks in a datasource.
curl --request GET \
     --url https://api.orq.ai/v2/knowledge/<knowledge_id>/datasources/<datasource_id>/chunks \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <API_KEY>'

Chunk Strategy

When using the AI Studio, you only have access to the following chunk strategies. For more options, see the API & SDK tab.
Automatically set chunk and preprocessing rules. Recommended for unfamiliar users.
Maximum Chunk Length: Defines the maximum size of each chunk. Larger size means more information per chunk.Chunk Overlap: Defines the number of characters overlapping neighboring chunks. Higher values increase redundancy between chunks but improve the likelihood that relevant information is returned to models.
Use the sidebar to preview chunks using the chosen chunking strategy.

Chunk Metadata

Each chunk in a Knowledge Base can carry a metadata object: a set of key-value pairs that describe the chunk’s origin, topic, or any custom attribute relevant to your use case. Metadata lets you store all your content in a single Knowledge Base while still scoping retrieval to exactly the right subset of chunks at query time. Common use cases:
  • Multi-tenant RAG: tag chunks by client_id to isolate results per customer.
  • Source filtering: filter by filetype or source to restrict results to PDFs, support tickets, or a specific data feed.
  • Topic scoping: tag chunks by topic or category and filter queries to stay on a single subject.
Open a chunk from the datasource view to access the Edit Chunk panel. The panel has three sections:
  • Text: the chunk content.
  • Metadata: a JSON editor pre-filled with the current metadata, or {} if none has been set.
  • Enabled: toggle to enable or disable the chunk.
Edit the metadata JSON directly and save. The metadata object must be valid JSON with all values as strings, numbers, or booleans. Nested arrays or objects are not supported.

Data and PII Cleanup

Modify the data loaded within your sources to clean or anonymize it. Toggle on each cleanup option within the Data Cleanup panel.
OptionDescription
Delete emailsRemoves email addresses from chunk content
Delete credit cardsRemoves credit card numbers from chunk content
Delete phone numbersRemoves phone numbers from chunk content
Clean bullet pointsNormalizes bullet point formatting
Clean numbered listsNormalizes numbered list formatting
Clean unicodeRemoves or normalizes non-standard unicode characters
Clean dashesRemoves or normalizes dash characters
Clean whitespacesRemoves excess whitespace from chunk content

Embedding Models

An embedding model is a machine learning tool that transforms complex, high-dimensional data into simpler, numerical values that machines can understand, enabling semantic search. Configure which embedding model to use to query the Knowledge Base from the Knowledge Settings panel.

Agentic RAG

Incorporates AI agents into the RAG pipeline to orchestrate its components and perform additional actions beyond simple information retrieval, overcoming the limitations of a non-agentic pipeline. Enable the Agentic RAG toggle in Knowledge Settings, then select a Model to use. The chosen model drives two actions:
  • Document Grading: ensures only relevant chunks are retrieved.
  • Query Refinement: rewrites the query if needed to improve retrieval quality.
See the screenshot below on how the input query gets refined.Input query: is my suitcase too big? is reformulated to luggage size requirements and restrictions for carry-on and checked baggage

Search Modes

Different Search modes are available for Information to be found in Knowledge Bases:
Search Settings
Sets the number of chunks most similar to the user’s question to return.
Controls the relevance of results on a scale from 0 to 1. Results scoring below the threshold are excluded from retrieval.The closer to 1, the more relevant and narrow the results will be.
Setting too high a threshold can yield little to no results.

Rerank Model

Reranking invokes a model that analyzes your initial query and the results fetched by the Knowledge Base search. The model scores and ranks the chunks by similarity to the user query, ensuring the most relevant results are returned.
To use reranking, you must enable at least one Reranking model within the AI Router.

Search a Knowledge Base

Once your Knowledge Base is populated, you can query it in several ways.
Test your Knowledge Base search directly in the AI Studio using the built-in search panel.
1

Open Knowledge Settings

Navigate to your Knowledge Base and click Knowledge Settings.
2

Enter your search query

Type your query in the Search query field in the right panel.
3

View results

Results appear below showing:
  • Document name (e.g., “Logistics FAQ.docx”)
  • Relevance score for each chunk (e.g., 0.49, 0.48)
  • Chunk content preview
Experiment with different search modes and threshold values to find the optimal configuration for your use case. Lower thresholds return more results but may include less relevant chunks.
Attach a Knowledge Base to a Deployment to automatically retrieve relevant chunks on every call.
  1. Open the Deployment’s configuration and go to Knowledge Bases.
  2. Select Knowledge Base and choose your Knowledge Base.
  3. Set the query type:
    • Last User Message: the user’s latest message is used as the search query automatically.
    • Query: use a predefined query. You can make it dynamic with an input variable such as {{query}}.
  4. Reference the retrieved chunks in your prompt with the {{knowledge_base_key}} syntax. If not explicitly referenced, the chunks are appended to the end of the system message.
Add a Knowledge Base as context to an Agent. Unlike Deployments, the Agent only queries the Knowledge Base when it determines it is necessary, using the query_knowledge_base tool automatically.
  1. In the Agent configuration, go to the Context section and click Add context.
  2. Select your Knowledge Base.
  3. In the Agent’s Instructions, explicitly tell it to use the Knowledge Base. For example:
“First use retrieve_knowledge_bases to see what knowledge sources are available, then use query_knowledge_base to find relevant information before answering.”
The Knowledge Base description must be explicit so the Agent can identify the right source to query.
To learn more, see Knowledge Bases with Agents.
To add a Knowledge Base in a Prompt, open the Knowledge Base tab in the Configuration screen and select Add a Knowledge Base.
Choose whether the Knowledge Base type is Last User Message or Query. This defines how the Knowledge Base will be queried.Use the {{key}} syntax in your prompt, where key is the key of your Knowledge Base.
Last User Message: the user message is used as a query to retrieve the relevant chunks.
Query: your predefined query is used to retrieve the relevant chunks.Within a Deployment context, make the query dynamic by using an input variable in the query field.
See knowledge base retrieval in a complete application. Read our cookbooks Multilingual FAQ Bot and Customer Support Chat.

Retrieval Traces and Logs

When using a Knowledge Base within Playground, Experiment, Deployment, or Agent, traces are generated containing details of how Knowledge Bases were accessed.
To find Traces, go to the Traces tab in the AI Studio.
Retrieval Spans show the following:
  • Query: the query used to retrieve relevant chunks.
  • Documents: the retrieved chunks, ordered by relevance score.

External Knowledge Bases

To connect to an external Knowledge Base, click the + button on the desired Project and select Knowledge Base > External.
The following modal opens to configure the external knowledge base.
Connect External Kb
FieldDescriptionExample
KeyUnique identifier, alphanumeric with hyphens/underscoresexternal_kb
DescriptionDescription of the knowledge baseExternal Knowledge Base
NameDisplay nameExternal Knowledge Base Name
API URLURL to search the knowledge base, must be HTTPShttps://api.example.org/search
API KeyAuthentication API key. Orq.ai will use Bearer Authentication to call your API.<API_KEY>
orq.ai includes the API Key in the Authorization: Bearer <API_KEY> header when calling your endpoint.
API keys are encrypted using workspace-specific keys (AES-256-GCM).
Select Connect to finalize.

API Payloads

Example payloads for the request and response expected from your external API:
{
  "query": "<string>",
  "top_k": 50,
  "threshold": 0.5,
  "filter_by": {},
  "search_options": {
    "include_vectors": true,
    "include_metadata": true,
    "include_scores": true
  },
  "rerank_config": {
    "model": "cohere/rerank-multilingual-v3.0",
    "threshold": 0,
    "top_k": 10
  }
}
{
  "matches": [
    {
      "id": "<string>",
      "text": "<string>",
      "vector": [123],
      "metadata": {},
      "scores": {
        "rerank_score": 123,
        "search_score": 123
      }
    }
  ]
}
The API must respond like a standard Knowledge Base search. See our Search API for the expected payload format.

Example Implementations

Get the Code

Install Dependencies

pip install -r requirements.txt

Run the Server

uvicorn main:app --reload

Test the API

The API is running at http://localhost:8000Dynamic Documentation is available at http://localhost:8000/docs

Get the Code

Install Dependencies

npm install

Run the Server

npm run dev

Test the API

The API is running at http://localhost:8000Dynamic Documentation is available at http://localhost:8000/doc

Integrate Vector Database Providers

Orq.ai supports providers like Weaviate and Pinecone, as both platforms expose REST APIs that conform to the expected payload format.

Troubleshoot Common Errors

ScenarioError Message
HTTP instead of HTTPS”External knowledge base URL must use HTTPS protocol”
Local/private IP”External knowledge base URL cannot point to local network”
API unreachable”Failed to verify external knowledge base connectivity”
API timeout (>50s)“External API request timed out”
Cannot connect to external API
  1. Verify your API endpoint is publicly accessible via HTTPS.
  2. Check your API logs for incoming requests from orq.ai IP addresses.
  3. Verify your firewall/security groups allow inbound HTTPS traffic.
API key authentication failing
  1. Verify the API key is correct and has not expired.
  2. Check that your API expects Bearer authentication in the Authorization header.
  3. Confirm your API key has the necessary permissions to perform searches.
No results returned or poor quality results
  1. Verify your API returns the expected response format (see Response Payload above).
  2. Check that scores.search_score values are between 0 and 1.
  3. Test with different threshold values (lower threshold = more results).
  4. If using reranking, ensure both search_score and rerank_score are provided.
  5. Verify your external vector database has sufficient indexed documents.
Slow response times
  1. Monitor your external API response times.
  2. Consider implementing caching for frequently searched queries.
  3. Optimize your vector database indexes.
  4. Check if your external API is rate limiting requests.

Configure your External Knowledge Base

Datasource configuration is not accessible within External Knowledge Bases, as data is hosted outside of Orq.ai.
The available configurations are:
For detailed configuration options, see Embedding Models, Agentic RAG, Search Modes, and Rerank Model above. All settings apply to both internal and external Knowledge Bases.
Your External Knowledge Base is connected:

Memory Stores

Memory Stores provide persistent storage for agent memories, allowing agents to retain and retrieve information across conversations and sessions. Unlike Knowledge Bases, Memory Stores are entity-scoped: each Memory within a store is tied to a specific entity (a user, session, or any object you define), enabling personalized, per-entity recall. Only long-term memory is currently supported: stored information persists indefinitely with no automatic expiration. To use a Memory Store with an Agent, see Connect Memory Stores.

Architecture

ConceptDescription
Memory StoreTop-level container organizing all memories for a use case
MemoryAn entity within the store (e.g., a specific user, customer, or session)
Memory DocumentThe actual content item stored within a Memory, embedded for semantic search

Create a Memory Store

Head to a Project, use the button, and select Knowledge > Memory Store.
Creating Memory Stores
The following modal opens:
Memory Store Create
Ensure the description is thorough, as Agents use it to identify the correct Memory Store:
  • Good example: “Customer communication preferences, contact times, and support tier information for personalized outreach”
  • Bad example: “Customer data”

Manage Memories and Documents

A Memory represents a specific entity within a Memory Store, identified by an entity_id. Each Memory holds Documents: the actual text content embedded for semantic search.
Create an EntityOnce a Memory Store is created, select Add Entity, enter an ID for the entity, and press Save.
Memory Add Entity Studio
View MemoriesSelect an entity to see all Memory Documents stored for it. Each document shows the date it was recorded. Use date filters to narrow results.
Memory Store Date Filter
Add a Memory DocumentUse Add Memory to manually add a Memory Document to an entity. Fill in the content and press Add Memory.
Memories are best managed dynamically through the API. See the API & SDK tab for programmatic access.

Best Practices

Entity ID strategy: Use consistent, unique identifiers. Prefix by type (e.g., user_123, session_456) and keep IDs stable across your system. Descriptions: Write exhaustive Memory Store descriptions. Agents use them to identify the correct store to query. Organization: Create separate stores for different contexts (customers, products, sessions). Use descriptive keys. Metadata: Use tags for filtering and categorization, not for storing large text content. Keep data types consistent per field.
See Memory Stores powering real agent applications. Read our cookbooks Multi-Agent HR System and Chat History.