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

# 建立知識庫

> 為專案建立知識庫

## 請求

```bash theme={null}
POST https://api.pathors.com/v1/projects/{projectId}/knowledgebases
```

### 路徑參數

<ParamField path="projectId" type="string" required>專案 ID</ParamField>

### 標頭

<ParamField header="Authorization" type="string" required>
  使用您的 Developer Key 進行 Bearer 令牌認證
</ParamField>

### 請求主體

<ParamField body="name" type="string" required>知識庫的名稱</ParamField>

<ParamField body="type" type="string">
  知識庫後端：`pinecone` 或 `pgvector`。選填 — 省略時採用部署層預設值。
</ParamField>

<ParamField body="embeddingModelName" type="string">
  嵌入模型。選填 — 省略時採用部署層預設值。`pinecone` 知識庫固定使用 `llama-text-embed-v2`（整合式嵌入）；`pgvector` 支援 OpenAI 模型（如 `text-embedding-3-small`）、Cohere 模型，或部署層設定的自架模型。建立後無法變更。
</ParamField>

<ParamField body="chunkSize" type="number">區塊的最大字元數。預設為 `500`。</ParamField>
<ParamField body="chunkOverlap" type="number">相鄰區塊之間重疊的字元數。預設為 `50`。</ParamField>

## 回應

回傳建立的知識庫，狀態碼為 `201`。

### 範例

```bash theme={null}
curl -X POST https://api.pathors.com/v1/projects/{projectId}/knowledgebases \
  -H "Authorization: Bearer dk_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Knowledge Base",
    "type": "pgvector",
    "embeddingModelName": "text-embedding-3-small",
    "chunkSize": 500,
    "chunkOverlap": 50
  }'
```

```json theme={null}
{
  "message": "Knowledgebase created successfully"
}
```

<Note>
  目前每個專案限制只能有一個知識庫。
</Note>
