> ## 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.

# Knowledge SDK Reference

> Manage knowledge bases with the Node.js and Python SDKs: create and search knowledge bases and manage datasources and chunks for RAG retrieval.

## 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 first

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  from 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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      startingAfter?: string;
      endingBefore?: string;
      limit?: number;
      search?: string;
      updatedBy?: string;
      type?: "internal" | "external";
      projectId?: string;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "object": Literal["list"],
        "data": List[Union[Knowledge1, Knowledge2]],
        "has_more": bool,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      object: "list";
      data: (Knowledge1 | Knowledge2)[];
      hasMore: boolean;
    }
    ```
  </CodeGroup>
</Expandable>

### 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.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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[];
      };
    }
    ```
  </CodeGroup>
</Expandable>

### Retrieve a Knowledge Base

Retrieve a knowledge base with the settings.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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[];
      };
    }
    ```
  </CodeGroup>
</Expandable>

### Delete a Knowledge Base

Deletes a knowledge base. Deleting a knowledge base will delete all the datasources and chunks associated with it.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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 ...

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

### Update a Knowledge Base

Updates a knowledge base. Omitted optional fields retain their current values.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      knowledgeBasesServiceUpdateRequest: KnowledgeBasesServiceUpdateRequest1 | KnowledgeBasesServiceUpdateRequest2;  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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[];
      };
    }
    ```
  </CodeGroup>
</Expandable>

### 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.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "starting_after": Optional[str],
        "ending_before": Optional[str],
        "q": Optional[str],
        "limit": Optional[int],
        "status": Union[List[str], str],  # optional
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      startingAfter?: string;
      endingBefore?: string;
      q?: string;
      limit?: number;
      status?: string[] | string;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
    }
    ```
  </CodeGroup>
</Expandable>

### 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.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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],
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
        };
      };
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
    }
    ```
  </CodeGroup>
</Expandable>

### Preview Chunks

Parses an uploaded file and returns the chunks it would produce for the given chunking options without creating a datasource.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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],
            },
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
          };
        };
      };
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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,
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      chunks: {
        text: string;
        pageNumber?: number;
      }[];
      metadata: {
        wordsCount: number;
        sentencesCount: number;
        paragraphsCount: number;
        tokensCount: number;
        charactersCount: number;
        chunksCount: number;
      };
    }
    ```
  </CodeGroup>
</Expandable>

### Retrieve Datasource

Retrieves a datasource and its current processing status and chunk count.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "datasource_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
    }
    ```
  </CodeGroup>
</Expandable>

### 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.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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 ...

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "datasource_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

### Update Datasource

Updates the display name of a datasource.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "datasource_id": str,  # required
        "display_name": str,  # required
        "description": Optional[str],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
      datasourcesServiceUpdateRequest: {  // required
        displayName: string;  // required
        description?: string;
      };
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
    }
    ```
  </CodeGroup>
</Expandable>

### List Chunks

Returns chunks using cursor pagination, with optional text and processing-status filters.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
      limit?: number;
      startingAfter?: string;
      endingBefore?: string;
      q?: string;
      status?: QueryParam1[] | QueryParam2;
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
    }
    ```
  </CodeGroup>
</Expandable>

### Create Chunks

Creates between 1 and 100 chunks. Chunks with supplied embeddings are indexed immediately; chunks without embeddings are queued for embedding.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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],
        }],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
      requestBody: {  // required
        text: string;  // required
        embedding?: number[];
        metadata?: Record<string, string | number | boolean>;
        id?: string;
      }[];
    }
    ```
  </CodeGroup>
</Expandable>

### Delete Chunks

Deletes up to 100 chunks and reports IDs that were not found or could not be deleted.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "datasource_id": str,  # required
        "chunk_ids": List[str],  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
      chunksServiceDeleteManyRequest: {  // required
        chunkIds: string[];  // required
      };
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "deleted_count": float,
        "failed_ids": List[str],  # optional
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      deletedCount: number;
      failedIds?: string[];
    }
    ```
  </CodeGroup>
</Expandable>

### Get Chunks Count

Returns the total count of chunks in a datasource. When `q` is provided, the count reflects indexed chunks only: recently created chunks may not be counted until embedding completes.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "datasource_id": str,  # required
        "q": Optional[str],
        "enabled": Optional[bool],
        "status": Optional[Literal["pending", "processing", "completed", "failed", "queued"]],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
      chunksServiceCountRequest: {  // required
        q?: string;
        enabled?: boolean;
        status?: "pending" | "processing" | "completed" | "failed" | "queued";
      };
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "count": float,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      count: number;
    }
    ```
  </CodeGroup>
</Expandable>

### List Chunks Paginated

Returns a page of chunks, with optional text, enabled-state, and processing-status filters.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
      chunksServiceListPaginatedRequest: {  // required
        q?: string;
        enabled?: boolean;
        status?: "pending" | "processing" | "completed" | "failed" | "queued";
        limit?: number;
        page?: number;
      };
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
    }
    ```
  </CodeGroup>
</Expandable>

### Retrieve Chunk

Retrieves a chunk by its chunk identifier.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "datasource_id": str,  # required
        "chunk_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
      chunkId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
    }
    ```
  </CodeGroup>
</Expandable>

### Delete Chunk

Deletes a chunk from the datasource and its vector index.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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 ...

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "datasource_id": str,  # required
        "chunk_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
      chunkId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

### Update Chunk

Updates chunk text, metadata, or a supplied embedding. Changing text without an embedding queues the chunk for re-embedding.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
      chunkId: string;  // required
      chunksServiceUpdateRequest: {  // required
        text?: string;
        embedding?: number[];
        metadata?: Record<string, string | number | boolean>;
      };
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
    }
    ```
  </CodeGroup>
</Expandable>

### Toggle Chunk

Enables or disables a chunk for retrieval. If the vector-index document is missing, enabling the chunk queues it for embedding.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "datasource_id": str,  # required
        "chunk_id": str,  # required
        "enabled": bool,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
      chunkId: string;  // required
      chunksServiceSetEnabledRequest: {  // required
        enabled: boolean;  // required
      };
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
    }
    ```
  </CodeGroup>
</Expandable>

### Retrieve Processing Status

Returns aggregate queued, completed, passed, and failed chunk counts together with the datasource and chunk processing attempts.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "datasource_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      datasourceId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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],
        }],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
      }[];
    }
    ```
  </CodeGroup>
</Expandable>

### 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.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "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],
            },
        },
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      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;
          };
        };
      };
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "matches": [{
            "id": str,
            "text": str,
            "vector": List[float],  # optional
            "metadata": Dict[str, Any],  # optional
            "scores": {  # optional
                "rerank_score": Optional[float],
                "search_score": Optional[float],
            },
        }],
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      matches: {
        id: string;
        text: string;
        vector?: number[];
        metadata?: Record<string, unknown>;
        scores?: {
          rerankScore?: number;
          searchScore?: number;
        };
      }[];
    }
    ```
  </CodeGroup>
</Expandable>

### 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.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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)

  ```

  ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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();
  ```
</CodeGroup>

<Expandable title="Parameters">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "knowledge_id": str,  # required
        "file_name": str,  # required
        "content_type": str,  # required
        "datasource_id": str,  # required
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      knowledgeId: string;  // required
      fileName: string;  // required
      contentType: string;  // required
      datasourceId: string;  // required
    }
    ```
  </CodeGroup>
</Expandable>

<Expandable title="Response">
  <CodeGroup>
    ```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
        "object_name": str,
        "post_policy": {
            "post_url": str,
            "form_data": Dict[str, Any],
        },
        "file_id": str,
    }
    ```

    ```typescript Node.js theme={"theme":{"light":"github-light","dark":"github-dark"}}
    {
      objectName: string;
      postPolicy: {
        postURL: string;
        formData: Record<string, any>;
      };
      fileId: string;
    }
    ```
  </CodeGroup>
</Expandable>


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