跳转至

将新文本文档添加到向量存储

POST /vector-stores/{vector-store-id}/documents/create

Create a new text document in a vector store.

Parameter In Type Required Description
vector-store-id path string yes The ID of the vector store.
x-api-key header string yes The API key for authentication.

Request body

Field Type Required Description
name string The name of the document.
text string The text content of the document.

Responses

  • 201 — Document created successfully.

示例请求

curl -X POST   
  https://api.rememberizer.ai/api/v1/vector-stores/vs_abc123/documents/create   
  -H "x-api-key: YOUR_API_KEY"   
  -H "Content-Type: application/json"   
  -d '{
    "name": "产品概述",
    "text": "我们的产品是一个创新的解决方案,用于管理向量嵌入。它与您现有的系统无缝集成,并提供强大的语义搜索功能。"
  }'

Info

YOUR_API_KEY 替换为您的实际向量存储 API 密钥,将 vs_abc123 替换为您的向量存储 ID。

const addTextDocument = async (vectorStoreId, name, text) => {
  const response = await fetch(`https://api.rememberizer.ai/api/v1/vector-stores/${vectorStoreId}/documents/create`, {
    method: 'POST',
    headers: {
      'x-api-key': 'YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      name: name,
      text: text
    })
  });

  const data = await response.json();
  console.log(data);
};

addTextDocument(
  'vs_abc123',
  '产品概述',
  '我们的产品是一个创新的解决方案,用于管理向量嵌入。它与您现有的系统无缝集成,并提供强大的语义搜索功能。'
);

Info

YOUR_API_KEY 替换为您的实际向量存储 API 密钥,将 vs_abc123 替换为您的向量存储 ID。

import requests
import json

def add_text_document(vector_store_id, name, text):
    headers = {
        "x-api-key": "YOUR_API_KEY",
        "Content-Type": "application/json"
    }

    payload = {
        "name": name,
        "text": text
    }

    response = requests.post(
        f"https://api.rememberizer.ai/api/v1/vector-stores/{vector_store_id}/documents/create",
        headers=headers,
        data=json.dumps(payload)
    )

    data = response.json()
    print(data)

add_text_document(
    'vs_abc123',
    '产品概述',
    '我们的产品是一个创新的解决方案,用于管理向量嵌入。它与您现有的系统无缝集成,并提供强大的语义搜索功能。'
)

Info

YOUR_API_KEY 替换为您的实际向量存储 API 密钥,将 vs_abc123 替换为您的向量存储 ID。

路径参数

参数 类型 描述
vector-store-id 字符串 必需。 要添加文档的向量存储的 ID。

请求体

{
  "name": "产品概述",
  "text": "我们的产品是一个用于管理向量嵌入的创新解决方案。它与您现有的系统无缝集成,并提供强大的语义搜索功能。"
}
参数 类型 描述
name string 必填。 文档的名称。
text string 必填。 文档的文本内容。

响应格式

{
  "id": 1234,
  "name": "产品概述",
  "type": "text/plain",
  "vector_store": "vs_abc123",
  "size": 173,
  "status": "处理中",
  "processing_status": "排队中",
  "indexed_on": null,
  "status_error_message": null,
  "created": "2023-06-15T10:15:00Z",
  "modified": "2023-06-15T10:15:00Z"
}

认证

此端点需要使用 x-api-key 头中的 API 密钥进行认证。

错误响应

状态码 描述
400 错误请求 - 缺少必需字段或格式无效
401 未授权 - API 密钥无效或缺失
404 未找到 - 找不到向量存储
500 内部服务器错误

此端点允许您直接将文本内容添加到您的向量存储中。它特别适用于存储可能不存在于文件格式中的信息,例如产品描述、知识库文章或自定义内容。文本将自动处理为向量嵌入,使其可以通过语义相似性进行搜索。