Returns a list of your knowledge bases. The knowledge bases are returned sorted by creation date, with the most recent knowledge bases appearing first
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.list(limit=10)
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
limit |
Optional[int] |
➖ |
A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10 |
starting_after |
Optional[str] |
➖ |
A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list. |
ending_before |
Optional[str] |
➖ |
A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.ListKnowledgeBasesResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Create a knowledge
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.create(request={
"type": "internal",
"key": "<key>",
"embedding_model": "<value>",
"path": "Default",
})
# Handle response
print(res)
models.CreateKnowledgeResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Retrieve a knowledge base with the settings.
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.retrieve(knowledge_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
Unique identifier of the knowledge base |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.GetOneKnowledgeResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Updates a knowledge
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.update(knowledge_id="<id>", request_body={
"path": "Default",
"type": "external",
})
# Handle response
print(res)
models.UpdateKnowledgeResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Deletes a knowledge base. Deleting a knowledge base will delete all the datasources and chunks associated with it.
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
orq.knowledge.delete(knowledge_id="<id>")
# Use the SDK ...
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Search a Knowledge Base and return the most similar chunks, along with their search and rerank scores. Note that all configuration changes made in the API will override the settings in the UI.
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.search(knowledge_id="<id>", query="<value>", search_type="hybrid_search", rerank_config={
"model": "cohere/rerank-multilingual-v3.0",
})
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
The unique identifier or key of the knowledge base |
query |
str |
✔️ |
The query to use to search the knowledge base |
top_k |
Optional[int] |
➖ |
The number of results to return. If not provided, will default to the knowledge base configured top_k. |
threshold |
Optional[float] |
➖ |
The threshold to apply to the search. If not provided, will default to the knowledge base configured threshold |
search_type |
Optional[models.SearchType] |
➖ |
The type of search to perform. If not provided, will default to the knowledge base configured retrieval_type |
filter_by |
Optional[models.FilterBy] |
➖ |
The metadata filter to apply to the search. Check the Searching a Knowledge Base for more information. |
search_options |
Optional[models.SearchOptions] |
➖ |
Additional search options |
rerank_config |
Optional[models.RerankConfig] |
➖ |
Override the rerank configuration for this search. If not provided, will use the knowledge base configured rerank settings. |
agentic_rag_config |
Optional[models.AgenticRagConfig] |
➖ |
Override the agentic RAG configuration for this search. If not provided, will use the knowledge base configured agentic RAG settings. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.SearchKnowledgeResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
List all datasources
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.list_datasources(knowledge_id="<id>", limit=50, status=[
"completed",
"failed",
])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
Unique identifier of the knowledge base |
starting_after |
Optional[str] |
➖ |
A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list. |
ending_before |
Optional[str] |
➖ |
A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list. |
q |
Optional[str] |
➖ |
Search query to find datasources by name. |
limit |
Optional[float] |
➖ |
A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10 |
status |
Optional[models.QueryParamStatus] |
➖ |
Filter datasources by status. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.ListDatasourcesResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Create a new datasource
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.create_datasource(knowledge_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
display_name |
Optional[str] |
➖ |
The display name for the datasource visible in the UI. If omitted, the display name is derived from the uploaded file. When both display_name and file_id are provided, the provided display_name is prioritized. |
file_id |
Optional[str] |
➖ |
The unique identifier of the file used for datasource creation. If provided, the file is immediately queued for chunking. |
chunking_options |
Optional[models.ChunkingOptions] |
➖ |
Configuration options specifying how the datasource file is chunked. Required if file_id is specified. Defaults to standard chunking options if omitted. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.CreateDatasourceResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Retrieve a datasource
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.retrieve_datasource(knowledge_id="<id>", datasource_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
datasource_id |
str |
✔️ |
The unique identifier of the datasource. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.RetrieveDatasourceResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Deletes a datasource from a knowledge base. Deleting a datasource will remove it from the knowledge base and all associated chunks. This action is irreversible and cannot be undone.
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
orq.knowledge.delete_datasource(knowledge_id="<id>", datasource_id="<id>")
# Use the SDK ...
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
datasource_id |
str |
✔️ |
The unique identifier of the datasource. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Update a datasource
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.update_datasource(knowledge_id="<id>", datasource_id="<id>", display_name="Tony_Roberts")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
datasource_id |
str |
✔️ |
The unique identifier of the datasource. |
display_name |
str |
✔️ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.UpdateDatasourceResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Create chunks for a datasource
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.create_chunks(knowledge_id="<id>", datasource_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
Unique identifier of the knowledge |
datasource_id |
str |
✔️ |
Unique identifier of the datasource |
request_body |
List[models.RequestBody] |
➖ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
List[models.CreateChunkResponseBody]
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
List all chunks for a datasource
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.list_chunks(knowledge_id="<id>", datasource_id="<id>", limit=10, status=[
"completed",
"failed",
])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
datasource_id |
str |
✔️ |
The unique identifier of the datasource. |
limit |
Optional[int] |
➖ |
A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10 |
starting_after |
Optional[str] |
➖ |
A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list. |
ending_before |
Optional[str] |
➖ |
A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list. |
q |
Optional[str] |
➖ |
Search query to find datasources by name. |
status |
Optional[models.ListChunksQueryParamStatus] |
➖ |
Filter datasources by status. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.ListChunksResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Delete multiple chunks
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.delete_chunks(knowledge_id="<id>", datasource_id="<id>", chunk_ids=[
"<value 1>",
"<value 2>",
])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
datasource_id |
str |
✔️ |
The unique identifier of the datasource. |
chunk_ids |
List[str] |
✔️ |
Array of chunk IDs to delete |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.DeleteChunksResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
List chunks with offset-based pagination
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.list_chunks_paginated(knowledge_id="<id>", datasource_id="<id>", q="", limit=100, page=1)
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
datasource_id |
str |
✔️ |
The unique identifier of the datasource. |
q |
Optional[str] |
➖ |
Search query to find chunks by text content |
enabled |
Optional[bool] |
➖ |
Filter chunks by enabled status |
status |
Optional[str] |
➖ |
Filter chunks by processing status |
limit |
Optional[int] |
➖ |
N/A |
page |
Optional[int] |
➖ |
N/A |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.ListChunksPaginatedResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Get chunks total count
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.get_chunks_count(knowledge_id="<id>", datasource_id="<id>", q="")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
datasource_id |
str |
✔️ |
The unique identifier of the datasource. |
q |
Optional[str] |
➖ |
Search query to find chunks by text content |
enabled |
Optional[bool] |
➖ |
Filter chunks by enabled status |
status |
Optional[str] |
➖ |
Filter chunks by processing status |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.GetChunksCountResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Update a chunk
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.update_chunk(chunk_id="<id>", datasource_id="<id>", knowledge_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
chunk_id |
str |
✔️ |
The unique identifier of the chunk |
datasource_id |
str |
✔️ |
The unique identifier of the data source |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
text |
Optional[str] |
➖ |
The text content of the chunk |
embedding |
List[float] |
➖ |
The embedding vector of the chunk. If not provided the chunk will be embedded with the knowledge base embeddings model. |
metadata |
Dict[str, models.UpdateChunkMetadata] |
➖ |
Metadata of the chunk |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.UpdateChunkResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Delete a chunk
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
orq.knowledge.delete_chunk(chunk_id="<id>", datasource_id="<id>", knowledge_id="<id>")
# Use the SDK ...
| Parameter |
Type |
Required |
Description |
chunk_id |
str |
✔️ |
The unique identifier of the chunk |
datasource_id |
str |
✔️ |
The unique identifier of the data source |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |
Retrieve a chunk
from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.retrieve_chunk(chunk_id="<id>", datasource_id="<id>", knowledge_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
chunk_id |
str |
✔️ |
The unique identifier of the chunk |
datasource_id |
str |
✔️ |
The unique identifier of the data source |
knowledge_id |
str |
✔️ |
The unique identifier of the knowledge base |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.GetOneChunkResponseBody
| Error Type |
Status Code |
Content Type |
| models.APIError |
4XX, 5XX |
*/* |