Knowledge
List Knowledge Bases
Returns a list of your knowledge bases. The knowledge bases are returned sorted by creation date, with the most recent knowledge bases appearing firstfrom orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.list(limit=25)
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.list({});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"starting_after": Optional[str],
"ending_before": Optional[str],
"limit": Optional[int],
"search": Optional[str],
"updated_by": Optional[str],
"type": Optional[Literal["internal", "external"]],
"project_id": Optional[str],
}
{
startingAfter?: string;
endingBefore?: string;
limit?: number;
search?: string;
updatedBy?: string;
type?: "internal" | "external";
projectId?: string;
}
Show Response
Show Response
{
"object": Literal["list"],
"data": List[Union[Knowledge1, Knowledge2]],
"has_more": bool,
}
{
object: "list";
data: (Knowledge1 | Knowledge2)[];
hasMore: boolean;
}
Create a Knowledge Base
Creates an internal or external knowledge base. Internal knowledge bases embed and index uploaded content; external knowledge bases query the configured external retrieval API.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)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.create({
type: "internal",
key: "<key>",
embeddingModel: "<value>",
path: "Default",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"type": Optional[Literal["internal"]],
"key": str, # required
"description": Optional[str],
"embedding_model": str, # required
"retrieval_settings": { # optional
"retrieval_type": Optional[Literal["vector_search", "keyword_search", "hybrid_search"]],
"top_k": Optional[int],
"threshold": Optional[float],
"rerank_config": { # optional
"top_k": Optional[int],
"rerank_threshold": Optional[float],
"rerank_model": str, # required
},
"agentic_rag_config": { # optional
"model": str, # required
},
},
"path": str, # required
}
{
type?: "internal";
key: string; // required
description?: string;
embeddingModel: string; // required
retrievalSettings?: {
retrievalType?: "vector_search" | "keyword_search" | "hybrid_search";
topK?: number;
threshold?: number;
rerankConfig?: {
topK?: number;
rerankThreshold?: number;
rerankModel: string; // required
};
agenticRagConfig?: {
model: string; // required
};
};
path: string; // required
}
Show Response
Show Response
{
"id": str,
"created": str,
"description": Optional[str],
"key": str,
"domain_id": str,
"path": Optional[str],
"created_by_id": Optional[str],
"updated_by_id": Optional[str],
"updated": str,
"type": Optional[Literal["internal"]],
"retrieval_settings": { # optional
"retrieval_type": Optional[Literal["vector_search", "keyword_search", "hybrid_search"]],
"top_k": Optional[int],
"threshold": Optional[float],
"rerank_config": { # optional
"top_k": Optional[int],
"rerank_threshold": Optional[float],
"rerank_model": str,
},
"agentic_rag_config": { # optional
"model": str,
},
},
"model": str,
"settings": { # optional
"embeddings_config": { # optional
"provider": Optional[str],
"model": Optional[str],
"model_db_id": Optional[str],
"model_type": Optional[str],
"model_parameters": { # optional
"encoding_format": Optional[str],
"dimensions": Optional[int],
},
"integration_id": Optional[str],
},
"retrieval_config": { # optional
"type": Optional[str],
"top_k": Optional[int],
"threshold": Optional[float],
"rerank_config": { # optional
"enabled": Optional[bool],
"provider": Optional[str],
"top_k": Optional[int],
"model": Optional[str],
"model_db_id": Optional[str],
"model_type": Optional[str],
"model_parameters": { # optional
"threshold": Optional[float],
},
"integration_id": Optional[str],
},
},
"agentic_rag_config": { # optional
"model_db_id": Optional[str],
"provider": Optional[str],
"integration_id": Optional[str],
"model": Optional[str],
},
},
"metadata": { # optional
"word_count": Optional[int],
"document_count": Optional[int],
"sentences_count": Optional[int],
"support_enabled": Optional[bool],
"unique_metadata_fields": List[str], # optional
},
}
{
id: string;
created: string;
description?: string;
key: string;
domainId: string;
path?: string;
createdById?: string;
updatedById?: string;
updated: string;
type?: "internal";
retrievalSettings?: {
retrievalType?: "vector_search" | "keyword_search" | "hybrid_search";
topK?: number;
threshold?: number;
rerankConfig?: {
topK?: number;
rerankThreshold?: number;
rerankModel: string;
};
agenticRagConfig?: {
model: string;
};
};
model: string;
settings?: {
embeddingsConfig?: {
provider?: string;
model?: string;
modelDbId?: string;
modelType?: string;
modelParameters?: {
encodingFormat?: string;
dimensions?: number;
};
integrationId?: string;
};
retrievalConfig?: {
type?: string;
topK?: number;
threshold?: number;
rerankConfig?: {
enabled?: boolean;
provider?: string;
topK?: number;
model?: string;
modelDbId?: string;
modelType?: string;
modelParameters?: {
threshold?: number;
};
integrationId?: string;
};
};
agenticRagConfig?: {
modelDbId?: string;
provider?: string;
integrationId?: string;
model?: string;
};
};
metadata?: {
wordCount?: number;
documentCount?: number;
sentencesCount?: number;
supportEnabled?: boolean;
uniqueMetadataFields?: string[];
};
}
Retrieve a Knowledge Base
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)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.retrieve({
knowledgeId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
}
{
knowledgeId: string; // required
}
Show Response
Show Response
{
"id": str,
"created": str,
"description": Optional[str],
"key": str,
"domain_id": str,
"path": Optional[str],
"created_by_id": Optional[str],
"updated_by_id": Optional[str],
"updated": str,
"type": Optional[Literal["internal"]],
"retrieval_settings": { # optional
"retrieval_type": Optional[Literal["vector_search", "keyword_search", "hybrid_search"]],
"top_k": Optional[int],
"threshold": Optional[float],
"rerank_config": { # optional
"top_k": Optional[int],
"rerank_threshold": Optional[float],
"rerank_model": str,
},
"agentic_rag_config": { # optional
"model": str,
},
},
"model": str,
"settings": { # optional
"embeddings_config": { # optional
"provider": Optional[str],
"model": Optional[str],
"model_db_id": Optional[str],
"model_type": Optional[str],
"model_parameters": { # optional
"encoding_format": Optional[str],
"dimensions": Optional[int],
},
"integration_id": Optional[str],
},
"retrieval_config": { # optional
"type": Optional[str],
"top_k": Optional[int],
"threshold": Optional[float],
"rerank_config": { # optional
"enabled": Optional[bool],
"provider": Optional[str],
"top_k": Optional[int],
"model": Optional[str],
"model_db_id": Optional[str],
"model_type": Optional[str],
"model_parameters": { # optional
"threshold": Optional[float],
},
"integration_id": Optional[str],
},
},
"agentic_rag_config": { # optional
"model_db_id": Optional[str],
"provider": Optional[str],
"integration_id": Optional[str],
"model": Optional[str],
},
},
"metadata": { # optional
"word_count": Optional[int],
"document_count": Optional[int],
"sentences_count": Optional[int],
"support_enabled": Optional[bool],
"unique_metadata_fields": List[str], # optional
},
}
{
id: string;
created: string;
description?: string;
key: string;
domainId: string;
path?: string;
createdById?: string;
updatedById?: string;
updated: string;
type?: "internal";
retrievalSettings?: {
retrievalType?: "vector_search" | "keyword_search" | "hybrid_search";
topK?: number;
threshold?: number;
rerankConfig?: {
topK?: number;
rerankThreshold?: number;
rerankModel: string;
};
agenticRagConfig?: {
model: string;
};
};
model: string;
settings?: {
embeddingsConfig?: {
provider?: string;
model?: string;
modelDbId?: string;
modelType?: string;
modelParameters?: {
encodingFormat?: string;
dimensions?: number;
};
integrationId?: string;
};
retrievalConfig?: {
type?: string;
topK?: number;
threshold?: number;
rerankConfig?: {
enabled?: boolean;
provider?: string;
topK?: number;
model?: string;
modelDbId?: string;
modelType?: string;
modelParameters?: {
threshold?: number;
};
integrationId?: string;
};
};
agenticRagConfig?: {
modelDbId?: string;
provider?: string;
integrationId?: string;
model?: string;
};
};
metadata?: {
wordCount?: number;
documentCount?: number;
sentencesCount?: number;
supportEnabled?: boolean;
uniqueMetadataFields?: string[];
};
}
Delete a Knowledge Base
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 ...
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
await orq.knowledge.delete({
knowledgeId: "<id>",
});
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
}
{
knowledgeId: string; // required
}
Update a Knowledge Base
Updates a knowledge base. Omitted optional fields retain their current values.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>", knowledge_bases_service_update_request={
"path": "Default",
"type": "internal",
})
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.update({
knowledgeId: "<id>",
knowledgeBasesServiceUpdateRequest: {
path: "Default",
type: "internal",
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"description": Optional[str],
"path": Optional[str],
"retrieval_settings": { # optional
"top_k": Optional[int],
"threshold": Optional[float],
"rerank_config": { # optional
"top_k": Optional[int],
"rerank_threshold": Optional[float],
"rerank_model": str, # required
},
"agentic_rag_config": { # optional
"model": str, # required
},
},
"external_config": { # optional
"name": Optional[str],
"api_url": Optional[str],
"api_key": Optional[str],
},
"type": Optional[Literal["external"]],
"settings": { # optional
"embeddings_config": { # optional
"provider": Optional[str],
"model": Optional[str],
"model_db_id": Optional[str],
"model_type": Optional[str],
"model_parameters": { # optional
"encoding_format": Optional[str],
"dimensions": Optional[int],
},
"integration_id": Optional[str],
},
"retrieval_config": Optional[Any],
"agentic_rag_config": Optional[Any],
},
"domain_id": Optional[str],
}
{
knowledgeId: string; // required
knowledgeBasesServiceUpdateRequest: KnowledgeBasesServiceUpdateRequest1 | KnowledgeBasesServiceUpdateRequest2; // required
}
Show Response
Show Response
{
"id": str,
"created": str,
"description": Optional[str],
"key": str,
"domain_id": str,
"path": Optional[str],
"created_by_id": Optional[str],
"updated_by_id": Optional[str],
"updated": str,
"type": Optional[Literal["internal"]],
"retrieval_settings": { # optional
"retrieval_type": Optional[Literal["vector_search", "keyword_search", "hybrid_search"]],
"top_k": Optional[int],
"threshold": Optional[float],
"rerank_config": { # optional
"top_k": Optional[int],
"rerank_threshold": Optional[float],
"rerank_model": str,
},
"agentic_rag_config": { # optional
"model": str,
},
},
"model": str,
"settings": { # optional
"embeddings_config": { # optional
"provider": Optional[str],
"model": Optional[str],
"model_db_id": Optional[str],
"model_type": Optional[str],
"model_parameters": { # optional
"encoding_format": Optional[str],
"dimensions": Optional[int],
},
"integration_id": Optional[str],
},
"retrieval_config": { # optional
"type": Optional[str],
"top_k": Optional[int],
"threshold": Optional[float],
"rerank_config": { # optional
"enabled": Optional[bool],
"provider": Optional[str],
"top_k": Optional[int],
"model": Optional[str],
"model_db_id": Optional[str],
"model_type": Optional[str],
"model_parameters": { # optional
"threshold": Optional[float],
},
"integration_id": Optional[str],
},
},
"agentic_rag_config": { # optional
"model_db_id": Optional[str],
"provider": Optional[str],
"integration_id": Optional[str],
"model": Optional[str],
},
},
"metadata": { # optional
"word_count": Optional[int],
"document_count": Optional[int],
"sentences_count": Optional[int],
"support_enabled": Optional[bool],
"unique_metadata_fields": List[str], # optional
},
}
{
id: string;
created: string;
description?: string;
key: string;
domainId: string;
path?: string;
createdById?: string;
updatedById?: string;
updated: string;
type?: "internal";
retrievalSettings?: {
retrievalType?: "vector_search" | "keyword_search" | "hybrid_search";
topK?: number;
threshold?: number;
rerankConfig?: {
topK?: number;
rerankThreshold?: number;
rerankModel: string;
};
agenticRagConfig?: {
model: string;
};
};
model: string;
settings?: {
embeddingsConfig?: {
provider?: string;
model?: string;
modelDbId?: string;
modelType?: string;
modelParameters?: {
encodingFormat?: string;
dimensions?: number;
};
integrationId?: string;
};
retrievalConfig?: {
type?: string;
topK?: number;
threshold?: number;
rerankConfig?: {
enabled?: boolean;
provider?: string;
topK?: number;
model?: string;
modelDbId?: string;
modelType?: string;
modelParameters?: {
threshold?: number;
};
integrationId?: string;
};
};
agenticRagConfig?: {
modelDbId?: string;
provider?: string;
integrationId?: string;
model?: string;
};
};
metadata?: {
wordCount?: number;
documentCount?: number;
sentencesCount?: number;
supportEnabled?: boolean;
uniqueMetadataFields?: string[];
};
}
List Datasources
Returns the datasources in a knowledge base. Use cursors to page through results and optional query or status filters to narrow the list.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)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.listDatasources({
knowledgeId: "<id>",
status: [
"completed",
"failed",
],
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"starting_after": Optional[str],
"ending_before": Optional[str],
"q": Optional[str],
"limit": Optional[int],
"status": Union[List[str], str], # optional
}
{
knowledgeId: string; // required
startingAfter?: string;
endingBefore?: string;
q?: string;
limit?: number;
status?: string[] | string;
}
Show Response
Show Response
{
"object": Literal["list"],
"data": [{
"display_name": str,
"description": Optional[str],
"status": Literal["pending", "processing", "completed", "failed", "queued"],
"file_id": Optional[str],
"created": str,
"updated": str,
"created_by_id": Optional[str],
"update_by_id": Optional[str],
"knowledge_id": str,
"chunks_count": float,
"processing_attempts": [{ # optional
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
"metadata": { # optional
"words_count": Optional[float],
"sentences_count": Optional[float],
"paragraphs_count": Optional[float],
"tokens_count": Optional[float],
"characters_count": Optional[float],
"chunks_count": Optional[float],
},
"attachment": { # optional
"id": Optional[str],
"object_name": Optional[str],
},
"id": str,
}],
"has_more": bool,
}
{
object: "list";
data: {
displayName: string;
description?: string;
status: "pending" | "processing" | "completed" | "failed" | "queued";
fileId?: string;
created: string;
updated: string;
createdById?: string;
updateById?: string;
knowledgeId: string;
chunksCount: number;
processingAttempts?: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
metadata?: {
wordsCount?: number;
sentencesCount?: number;
paragraphsCount?: number;
tokensCount?: number;
charactersCount?: number;
chunksCount?: number;
};
attachment?: {
id?: string;
objectName?: string;
};
id: string;
}[];
hasMore: boolean;
}
Create Datasource
Creates a datasource shell when only a display name is provided. When file_id is provided, the uploaded file is queued for chunking and ingestion.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)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.createDatasource({
knowledgeId: "<id>",
datasourcesServiceCreateRequest: {},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"display_name": Optional[str],
"description": Optional[str],
"file_id": Optional[str],
"chunking_options": { # optional
"chunking_configuration": Union[ChunkingConfiguration1, ChunkingConfiguration2, ChunkingConfiguration3, ChunkingConfiguration4, ChunkingConfiguration5, ChunkingConfiguration6, ChunkingConfiguration7, ChunkingConfiguration8, ChunkingConfiguration9], # optional
"chunking_cleanup_options": { # optional
"delete_emails": Optional[bool],
"delete_credit_cards": Optional[bool],
"delete_phone_numbers": Optional[bool],
"clean_bullet_points": Optional[bool],
"clean_numbered_list": Optional[bool],
"clean_unicode": Optional[bool],
"clean_dashes": Optional[bool],
"clean_whitespaces": Optional[bool],
},
},
"id": Optional[str],
"attachment": { # optional
"id": Optional[str],
"object_name": Optional[str],
},
"metadata": { # optional
"words_count": Optional[float],
"sentences_count": Optional[float],
"paragraphs_count": Optional[float],
"tokens_count": Optional[float],
"characters_count": Optional[float],
"chunks_count": Optional[float],
},
}
{
knowledgeId: string; // required
datasourcesServiceCreateRequest: { // required
displayName?: string;
description?: string;
fileId?: string;
chunkingOptions?: {
chunkingConfiguration?: ChunkingConfiguration1 | ChunkingConfiguration2 | ChunkingConfiguration3 | ChunkingConfiguration4 | ChunkingConfiguration5 | ChunkingConfiguration6 | ChunkingConfiguration7 | ChunkingConfiguration8 | ChunkingConfiguration9;
chunkingCleanupOptions?: {
deleteEmails?: boolean;
deleteCreditCards?: boolean;
deletePhoneNumbers?: boolean;
cleanBulletPoints?: boolean;
cleanNumberedList?: boolean;
cleanUnicode?: boolean;
cleanDashes?: boolean;
cleanWhitespaces?: boolean;
};
};
id?: string;
attachment?: {
id?: string;
objectName?: string;
};
metadata?: {
wordsCount?: number;
sentencesCount?: number;
paragraphsCount?: number;
tokensCount?: number;
charactersCount?: number;
chunksCount?: number;
};
};
}
Show Response
Show Response
{
"display_name": str,
"description": Optional[str],
"status": Literal["pending", "processing", "completed", "failed", "queued"],
"file_id": Optional[str],
"created": str,
"updated": str,
"created_by_id": Optional[str],
"update_by_id": Optional[str],
"knowledge_id": str,
"chunks_count": float,
"processing_attempts": [{ # optional
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
"metadata": { # optional
"words_count": Optional[float],
"sentences_count": Optional[float],
"paragraphs_count": Optional[float],
"tokens_count": Optional[float],
"characters_count": Optional[float],
"chunks_count": Optional[float],
},
"attachment": { # optional
"id": Optional[str],
"object_name": Optional[str],
},
"id": str,
}
{
displayName: string;
description?: string;
status: "pending" | "processing" | "completed" | "failed" | "queued";
fileId?: string;
created: string;
updated: string;
createdById?: string;
updateById?: string;
knowledgeId: string;
chunksCount: number;
processingAttempts?: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
metadata?: {
wordsCount?: number;
sentencesCount?: number;
paragraphsCount?: number;
tokensCount?: number;
charactersCount?: number;
chunksCount?: number;
};
attachment?: {
id?: string;
objectName?: string;
};
id: string;
}
Preview Chunks
Parses an uploaded file and returns the chunks it would produce for the given chunking options without creating a datasource.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.preview_chunks(knowledge_id="<id>", file_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.previewChunks({
knowledgeId: "<id>",
datasourcesServicePreviewChunksRequest: {
fileId: "<id>",
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"file_id": str, # required
"chunking_options": { # optional
"chunking_configuration": Union[ChunkingConfiguration1, ChunkingConfiguration2, ChunkingConfiguration3, ChunkingConfiguration4, ChunkingConfiguration5, ChunkingConfiguration6, ChunkingConfiguration7, ChunkingConfiguration8, ChunkingConfiguration9], # optional
"chunking_cleanup_options": { # optional
"delete_emails": Optional[bool],
"delete_credit_cards": Optional[bool],
"delete_phone_numbers": Optional[bool],
"clean_bullet_points": Optional[bool],
"clean_numbered_list": Optional[bool],
"clean_unicode": Optional[bool],
"clean_dashes": Optional[bool],
"clean_whitespaces": Optional[bool],
},
},
}
{
knowledgeId: string; // required
datasourcesServicePreviewChunksRequest: { // required
fileId: string; // required
chunkingOptions?: {
chunkingConfiguration?: ChunkingConfiguration1 | ChunkingConfiguration2 | ChunkingConfiguration3 | ChunkingConfiguration4 | ChunkingConfiguration5 | ChunkingConfiguration6 | ChunkingConfiguration7 | ChunkingConfiguration8 | ChunkingConfiguration9;
chunkingCleanupOptions?: {
deleteEmails?: boolean;
deleteCreditCards?: boolean;
deletePhoneNumbers?: boolean;
cleanBulletPoints?: boolean;
cleanNumberedList?: boolean;
cleanUnicode?: boolean;
cleanDashes?: boolean;
cleanWhitespaces?: boolean;
};
};
};
}
Show Response
Show Response
{
"chunks": [{
"text": str,
"page_number": Optional[int],
}],
"metadata": {
"words_count": int,
"sentences_count": int,
"paragraphs_count": int,
"tokens_count": int,
"characters_count": int,
"chunks_count": int,
},
}
{
chunks: {
text: string;
pageNumber?: number;
}[];
metadata: {
wordsCount: number;
sentencesCount: number;
paragraphsCount: number;
tokensCount: number;
charactersCount: number;
chunksCount: number;
};
}
Retrieve Datasource
Retrieves a datasource and its current processing status and chunk count.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)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.retrieveDatasource({
knowledgeId: "<id>",
datasourceId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
}
{
knowledgeId: string; // required
datasourceId: string; // required
}
Show Response
Show Response
{
"display_name": str,
"description": Optional[str],
"status": Literal["pending", "processing", "completed", "failed", "queued"],
"file_id": Optional[str],
"created": str,
"updated": str,
"created_by_id": Optional[str],
"update_by_id": Optional[str],
"knowledge_id": str,
"chunks_count": float,
"processing_attempts": [{ # optional
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
"metadata": { # optional
"words_count": Optional[float],
"sentences_count": Optional[float],
"paragraphs_count": Optional[float],
"tokens_count": Optional[float],
"characters_count": Optional[float],
"chunks_count": Optional[float],
},
"attachment": { # optional
"id": Optional[str],
"object_name": Optional[str],
},
"id": str,
}
{
displayName: string;
description?: string;
status: "pending" | "processing" | "completed" | "failed" | "queued";
fileId?: string;
created: string;
updated: string;
createdById?: string;
updateById?: string;
knowledgeId: string;
chunksCount: number;
processingAttempts?: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
metadata?: {
wordsCount?: number;
sentencesCount?: number;
paragraphsCount?: number;
tokensCount?: number;
charactersCount?: number;
chunksCount?: number;
};
attachment?: {
id?: string;
objectName?: string;
};
id: string;
}
Delete Datasource
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 ...
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
await orq.knowledge.deleteDatasource({
knowledgeId: "<id>",
datasourceId: "<id>",
});
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
}
{
knowledgeId: string; // required
datasourceId: string; // required
}
Update Datasource
Updates the display name of 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="Product handbook")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.updateDatasource({
knowledgeId: "<id>",
datasourceId: "<id>",
datasourcesServiceUpdateRequest: {
displayName: "Product handbook",
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
"display_name": str, # required
"description": Optional[str],
}
{
knowledgeId: string; // required
datasourceId: string; // required
datasourcesServiceUpdateRequest: { // required
displayName: string; // required
description?: string;
};
}
Show Response
Show Response
{
"display_name": str,
"description": Optional[str],
"status": Literal["pending", "processing", "completed", "failed", "queued"],
"file_id": Optional[str],
"created": str,
"updated": str,
"created_by_id": Optional[str],
"update_by_id": Optional[str],
"knowledge_id": str,
"chunks_count": float,
"processing_attempts": [{ # optional
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
"metadata": { # optional
"words_count": Optional[float],
"sentences_count": Optional[float],
"paragraphs_count": Optional[float],
"tokens_count": Optional[float],
"characters_count": Optional[float],
"chunks_count": Optional[float],
},
"attachment": { # optional
"id": Optional[str],
"object_name": Optional[str],
},
"id": str,
}
{
displayName: string;
description?: string;
status: "pending" | "processing" | "completed" | "failed" | "queued";
fileId?: string;
created: string;
updated: string;
createdById?: string;
updateById?: string;
knowledgeId: string;
chunksCount: number;
processingAttempts?: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
metadata?: {
wordsCount?: number;
sentencesCount?: number;
paragraphsCount?: number;
tokensCount?: number;
charactersCount?: number;
chunksCount?: number;
};
attachment?: {
id?: string;
objectName?: string;
};
id: string;
}
List Chunks
Returns chunks using cursor pagination, with optional text and processing-status filters.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)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.listChunks({
knowledgeId: "<id>",
datasourceId: "<id>",
status: [
"completed",
"failed",
],
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
"limit": Optional[int],
"starting_after": Optional[str],
"ending_before": Optional[str],
"q": Optional[str],
"status": Union[List[QueryParam1], QueryParam2], # optional
}
{
knowledgeId: string; // required
datasourceId: string; // required
limit?: number;
startingAfter?: string;
endingBefore?: string;
q?: string;
status?: QueryParam1[] | QueryParam2;
}
Show Response
Show Response
{
"object": Literal["list"],
"data": [{
"text": str,
"metadata": Union[str, float, bool], # optional
"enabled": bool,
"status": Literal["pending", "processing", "completed", "failed", "queued"],
"created": str,
"updated": str,
"created_by_id": Optional[str],
"update_by_id": Optional[str],
"processing_attempts": [{ # optional
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
"count_metadata": { # optional
"words_count": Optional[float],
"sentences_count": Optional[float],
"paragraphs_count": Optional[float],
"tokens_count": Optional[float],
"characters_count": Optional[float],
"chunks_count": Optional[float],
},
"id": str,
}],
"has_more": bool,
}
{
object: "list";
data: {
text: string;
metadata?: Record<string, string | number | boolean>;
enabled: boolean;
status: "pending" | "processing" | "completed" | "failed" | "queued";
created: string;
updated: string;
createdById?: string;
updateById?: string;
processingAttempts?: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
countMetadata?: {
wordsCount?: number;
sentencesCount?: number;
paragraphsCount?: number;
tokensCount?: number;
charactersCount?: number;
chunksCount?: number;
};
id: string;
}[];
hasMore: boolean;
}
Create Chunks
Creates between 1 and 100 chunks. Chunks with supplied embeddings are indexed immediately; chunks without embeddings are queued for embedding.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>", request_body=[{"text": "sample text"}])
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.createChunks({
knowledgeId: "<id>",
datasourceId: "<id>",
requestBody: [{ text: "sample text" }],
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
"request_body": [{ # required
"text": str, # required
"embedding": List[float], # optional
"metadata": Union[str, float, bool], # optional
"id": Optional[str],
}],
}
{
knowledgeId: string; // required
datasourceId: string; // required
requestBody: { // required
text: string; // required
embedding?: number[];
metadata?: Record<string, string | number | boolean>;
id?: string;
}[];
}
Delete Chunks
Deletes up to 100 chunks and reports IDs that were not found or could not be deleted.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)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.deleteChunks({
knowledgeId: "<id>",
datasourceId: "<id>",
chunksServiceDeleteManyRequest: {
chunkIds: [
"<value 1>",
"<value 2>",
],
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
"chunk_ids": List[str], # required
}
{
knowledgeId: string; // required
datasourceId: string; // required
chunksServiceDeleteManyRequest: { // required
chunkIds: string[]; // required
};
}
Show Response
Show Response
{
"deleted_count": float,
"failed_ids": List[str], # optional
}
{
deletedCount: number;
failedIds?: string[];
}
Get Chunks Count
Returns the total count of chunks in a datasource. Whenq is provided, the count reflects indexed chunks only: recently created chunks may not be counted until embedding completes.
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)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.getChunksCount({
knowledgeId: "<id>",
datasourceId: "<id>",
chunksServiceCountRequest: {},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
"q": Optional[str],
"enabled": Optional[bool],
"status": Optional[Literal["pending", "processing", "completed", "failed", "queued"]],
}
{
knowledgeId: string; // required
datasourceId: string; // required
chunksServiceCountRequest: { // required
q?: string;
enabled?: boolean;
status?: "pending" | "processing" | "completed" | "failed" | "queued";
};
}
Show Response
Show Response
{
"count": float,
}
{
count: number;
}
List Chunks Paginated
Returns a page of chunks, with optional text, enabled-state, and processing-status filters.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)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.listChunksPaginated({
knowledgeId: "<id>",
datasourceId: "<id>",
chunksServiceListPaginatedRequest: {},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
"q": Optional[str],
"enabled": Optional[bool],
"status": Optional[Literal["pending", "processing", "completed", "failed", "queued"]],
"limit": Optional[int],
"page": Optional[int],
}
{
knowledgeId: string; // required
datasourceId: string; // required
chunksServiceListPaginatedRequest: { // required
q?: string;
enabled?: boolean;
status?: "pending" | "processing" | "completed" | "failed" | "queued";
limit?: number;
page?: number;
};
}
Show Response
Show Response
{
"object": Literal["list"],
"data": [{
"text": str,
"metadata": Union[str, float, bool], # optional
"enabled": bool,
"status": Literal["pending", "processing", "completed", "failed", "queued"],
"created": str,
"updated": str,
"created_by_id": Optional[str],
"update_by_id": Optional[str],
"processing_attempts": [{ # optional
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
"count_metadata": { # optional
"words_count": Optional[float],
"sentences_count": Optional[float],
"paragraphs_count": Optional[float],
"tokens_count": Optional[float],
"characters_count": Optional[float],
"chunks_count": Optional[float],
},
"id": str,
}],
"has_more": bool,
}
{
object: "list";
data: {
text: string;
metadata?: Record<string, string | number | boolean>;
enabled: boolean;
status: "pending" | "processing" | "completed" | "failed" | "queued";
created: string;
updated: string;
createdById?: string;
updateById?: string;
processingAttempts?: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
countMetadata?: {
wordsCount?: number;
sentencesCount?: number;
paragraphsCount?: number;
tokensCount?: number;
charactersCount?: number;
chunksCount?: number;
};
id: string;
}[];
hasMore: boolean;
}
Retrieve Chunk
Retrieves a chunk by its chunk identifier.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.retrieve_chunk(knowledge_id="<id>", datasource_id="<id>", chunk_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.retrieveChunk({
knowledgeId: "<id>",
datasourceId: "<id>",
chunkId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
"chunk_id": str, # required
}
{
knowledgeId: string; // required
datasourceId: string; // required
chunkId: string; // required
}
Show Response
Show Response
{
"text": str,
"metadata": Union[str, float, bool], # optional
"enabled": bool,
"status": Literal["pending", "processing", "completed", "failed", "queued"],
"created": str,
"updated": str,
"created_by_id": Optional[str],
"update_by_id": Optional[str],
"processing_attempts": [{ # optional
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
"count_metadata": { # optional
"words_count": Optional[float],
"sentences_count": Optional[float],
"paragraphs_count": Optional[float],
"tokens_count": Optional[float],
"characters_count": Optional[float],
"chunks_count": Optional[float],
},
"id": str,
}
{
text: string;
metadata?: Record<string, string | number | boolean>;
enabled: boolean;
status: "pending" | "processing" | "completed" | "failed" | "queued";
created: string;
updated: string;
createdById?: string;
updateById?: string;
processingAttempts?: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
countMetadata?: {
wordsCount?: number;
sentencesCount?: number;
paragraphsCount?: number;
tokensCount?: number;
charactersCount?: number;
chunksCount?: number;
};
id: string;
}
Delete Chunk
Deletes a chunk from the datasource and its vector index.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
orq.knowledge.delete_chunk(knowledge_id="<id>", datasource_id="<id>", chunk_id="<id>")
# Use the SDK ...
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
await orq.knowledge.deleteChunk({
knowledgeId: "<id>",
datasourceId: "<id>",
chunkId: "<id>",
});
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
"chunk_id": str, # required
}
{
knowledgeId: string; // required
datasourceId: string; // required
chunkId: string; // required
}
Update Chunk
Updates chunk text, metadata, or a supplied embedding. Changing text without an embedding queues the chunk for re-embedding.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.update_chunk(knowledge_id="<id>", datasource_id="<id>", chunk_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.updateChunk({
knowledgeId: "<id>",
datasourceId: "<id>",
chunkId: "<id>",
chunksServiceUpdateRequest: {},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
"chunk_id": str, # required
"text": Optional[str],
"embedding": List[float], # optional
"metadata": Union[str, float, bool], # optional
}
{
knowledgeId: string; // required
datasourceId: string; // required
chunkId: string; // required
chunksServiceUpdateRequest: { // required
text?: string;
embedding?: number[];
metadata?: Record<string, string | number | boolean>;
};
}
Show Response
Show Response
{
"text": str,
"metadata": Union[str, float, bool], # optional
"enabled": bool,
"status": Literal["pending", "processing", "completed", "failed", "queued"],
"created": str,
"updated": str,
"created_by_id": Optional[str],
"update_by_id": Optional[str],
"processing_attempts": [{ # optional
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
"count_metadata": { # optional
"words_count": Optional[float],
"sentences_count": Optional[float],
"paragraphs_count": Optional[float],
"tokens_count": Optional[float],
"characters_count": Optional[float],
"chunks_count": Optional[float],
},
"id": str,
}
{
text: string;
metadata?: Record<string, string | number | boolean>;
enabled: boolean;
status: "pending" | "processing" | "completed" | "failed" | "queued";
created: string;
updated: string;
createdById?: string;
updateById?: string;
processingAttempts?: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
countMetadata?: {
wordsCount?: number;
sentencesCount?: number;
paragraphsCount?: number;
tokensCount?: number;
charactersCount?: number;
chunksCount?: number;
};
id: string;
}
Toggle Chunk
Enables or disables a chunk for retrieval. If the vector-index document is missing, enabling the chunk queues it for embedding.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.toggle_chunk(knowledge_id="<id>", datasource_id="<id>", chunk_id="<id>", enabled=True)
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.toggleChunk({
knowledgeId: "<id>",
datasourceId: "<id>",
chunkId: "<id>",
chunksServiceSetEnabledRequest: {
enabled: true,
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
"chunk_id": str, # required
"enabled": bool, # required
}
{
knowledgeId: string; // required
datasourceId: string; // required
chunkId: string; // required
chunksServiceSetEnabledRequest: { // required
enabled: boolean; // required
};
}
Show Response
Show Response
{
"text": str,
"metadata": Union[str, float, bool], # optional
"enabled": bool,
"status": Literal["pending", "processing", "completed", "failed", "queued"],
"created": str,
"updated": str,
"created_by_id": Optional[str],
"update_by_id": Optional[str],
"processing_attempts": [{ # optional
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
"count_metadata": { # optional
"words_count": Optional[float],
"sentences_count": Optional[float],
"paragraphs_count": Optional[float],
"tokens_count": Optional[float],
"characters_count": Optional[float],
"chunks_count": Optional[float],
},
"id": str,
}
{
text: string;
metadata?: Record<string, string | number | boolean>;
enabled: boolean;
status: "pending" | "processing" | "completed" | "failed" | "queued";
created: string;
updated: string;
createdById?: string;
updateById?: string;
processingAttempts?: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
countMetadata?: {
wordsCount?: number;
sentencesCount?: number;
paragraphsCount?: number;
tokensCount?: number;
charactersCount?: number;
chunksCount?: number;
};
id: string;
}
Retrieve Processing Status
Returns aggregate queued, completed, passed, and failed chunk counts together with the datasource and chunk processing attempts.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.retrieve_processing_status(knowledge_id="<id>", datasource_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.retrieveProcessingStatus({
knowledgeId: "<id>",
datasourceId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"datasource_id": str, # required
}
{
knowledgeId: string; // required
datasourceId: string; // required
}
Show Response
Show Response
{
"total_queued": float,
"total_completed": float,
"total_passed": float,
"total_failed": float,
"overall_total_processing": float,
"chunks_processing_attempts": [{
"id": Optional[str],
"processing_attempts": [{ # optional
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
}],
"datasource_processing_attempts": [{
"id": str,
"started_at": str,
"queued_at": Optional[str],
"completed_at": Optional[str],
"errors": [{ # optional
"code": Optional[int],
"message": Optional[str],
}],
"retryable": Optional[bool],
}],
}
{
totalQueued: number;
totalCompleted: number;
totalPassed: number;
totalFailed: number;
overallTotalProcessing: number;
chunksProcessingAttempts: {
id?: string;
processingAttempts?: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
}[];
datasourceProcessingAttempts: {
id: string;
startedAt: string;
queuedAt?: string;
completedAt?: string;
errors?: {
code?: number;
message?: string;
}[];
retryable?: boolean;
}[];
}
Search a Knowledge Base
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>", rerank_config={
"model": "cohere/rerank-v4.0-pro",
})
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.search({
knowledgeId: "<id>",
searchKnowledgeRequest: {
query: "<value>",
rerankConfig: {
model: "cohere/rerank-v4.0-pro",
},
},
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"query": str, # required
"top_k": Optional[int],
"threshold": Optional[float],
"search_type": Optional[Literal["vector_search", "keyword_search", "hybrid_search"]],
"filter_by": Union[Dict[str, FilterBy1], SearchKnowledgeRequestFilterByAnd, SearchKnowledgeRequestFilterByOr], # optional
"search_options": { # optional
"include_vectors": Optional[bool],
"include_metadata": Optional[bool],
"include_scores": Optional[bool],
},
"rerank_config": { # optional
"model": str, # required
"threshold": Optional[float],
"top_k": Optional[int],
},
"agentic_rag_config": Union[AgenticRagConfig1, AgenticRagConfig2], # optional
"retrieval_config": { # optional
"type": Optional[Literal["vector_search", "keyword_search", "hybrid_search"]],
"top_k": Optional[int],
"threshold": Optional[float],
"rerank_config": { # optional
"enabled": Optional[bool],
"provider": Optional[str],
"top_k": Optional[int],
"model": Optional[str],
"model_db_id": Optional[str],
"model_type": Optional[Literal["rerank"]],
"model_parameters": { # optional
"threshold": Optional[float],
},
"integration_id": Optional[str],
},
},
}
{
knowledgeId: string; // required
searchKnowledgeRequest: { // required
query: string; // required
topK?: number;
threshold?: number;
searchType?: "vector_search" | "keyword_search" | "hybrid_search";
filterBy?: { [k: string]: FilterBy1 } | SearchKnowledgeRequestFilterByAnd | SearchKnowledgeRequestFilterByOr;
searchOptions?: {
includeVectors?: boolean;
includeMetadata?: boolean;
includeScores?: boolean;
};
rerankConfig?: {
model: string; // required
threshold?: number;
topK?: number;
};
agenticRagConfig?: AgenticRagConfig1 | AgenticRagConfig2;
retrievalConfig?: {
type?: "vector_search" | "keyword_search" | "hybrid_search";
topK?: number;
threshold?: number;
rerankConfig?: {
enabled?: boolean;
provider?: string;
topK?: number;
model?: string;
modelDbId?: string;
modelType?: "rerank";
modelParameters?: {
threshold?: number;
};
integrationId?: string;
};
};
};
}
Show Response
Show Response
{
"matches": [{
"id": str,
"text": str,
"vector": List[float], # optional
"metadata": Dict[str, Any], # optional
"scores": { # optional
"rerank_score": Optional[float],
"search_score": Optional[float],
},
}],
}
{
matches: {
id: string;
text: string;
vector?: number[];
metadata?: Record<string, unknown>;
scores?: {
rerankScore?: number;
searchScore?: number;
};
}[];
}
Retrieve File Url
Creates a presigned upload policy for a file that will be attached to a knowledge-base datasource. Submit the returned form fields and file directly to the returned URL.from orq_ai_sdk import Orq
import os
with Orq(
api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:
res = orq.knowledge.retrieve_file_url(knowledge_id="<id>", file_name="example.file", content_type="<value>", datasource_id="<id>")
# Handle response
print(res)
import { Orq } from "@orq-ai/node";
const orq = new Orq({
apiKey: process.env["ORQ_API_KEY"] ?? "",
});
async function run() {
const result = await orq.knowledge.retrieveFileUrl({
knowledgeId: "<id>",
fileName: "example.file",
contentType: "<value>",
datasourceId: "<id>",
});
console.log(result);
}
run();
Show Parameters
Show Parameters
{
"knowledge_id": str, # required
"file_name": str, # required
"content_type": str, # required
"datasource_id": str, # required
}
{
knowledgeId: string; // required
fileName: string; // required
contentType: string; // required
datasourceId: string; // required
}
Show Response
Show Response
{
"object_name": str,
"post_policy": {
"post_url": str,
"form_data": Dict[str, Any],
},
"file_id": str,
}
{
objectName: string;
postPolicy: {
postURL: string;
formData: Record<string, any>;
};
fileId: string;
}