Qdrant 托管云中的数据库认证

本页面向您展示如何使用Qdrant云控制台为集群创建数据库API密钥。您将学习如何使用新的API密钥连接到您的集群。

创建数据库API密钥

API密钥在创建后仅显示一次。如果您丢失了它,您将需要创建一个新的。 然而,我们建议定期轮换密钥。要创建额外的API密钥,请执行以下操作。

  1. Go to the 云仪表盘.
  2. Go to the API Keys section of the Cluster detail page.
  3. Click Create. If you have granular access control activated, you can now configure the permissions for the new key.
  4. Click OK and retrieve your API key.

测试集群访问

创建后,您将收到一个代码片段来访问您的集群。您生成的请求应该与这个非常相似:

curl \
  -X GET 'https://xyz-example.eu-central.aws.cloud.qdrant.io:6333' \
  --header 'api-key: <paste-your-api-key-here>'

打开终端并运行请求。您应该会得到如下所示的响应:

{"title":"qdrant - vector search engine","version":"1.8.1"}

注意: 您需要在每个通过REST或gRPC发出的请求的请求头中包含API密钥。

通过SDK进行认证

现在你已经创建了你的第一个集群和密钥,你可能想从你的应用程序中访问你的数据库。 我们的官方Qdrant客户端支持Python、TypeScript、Go、Rust、.NET和Java,所有这些客户端都支持API密钥参数。

curl \
  -X GET https://xyz-example.eu-central.aws.cloud.qdrant.io:6333 \
  --header 'api-key: <provide-your-own-key>'

# Alternatively, you can use the `Authorization` header with the `Bearer` prefix
curl \
  -X GET https://xyz-example.eu-central.aws.cloud.qdrant.io:6333 \
  --header 'Authorization: Bearer <provide-your-own-key>'
from qdrant_client import QdrantClient

qdrant_client = QdrantClient(
    "xyz-example.eu-central.aws.cloud.qdrant.io",
    api_key="<paste-your-api-key-here>",
)
import { QdrantClient } from "@qdrant/js-client-rest";

const client = new QdrantClient({
  host: "xyz-example.eu-central.aws.cloud.qdrant.io",
  apiKey: "<paste-your-api-key-here>",
});
use qdrant_client::Qdrant;

let client = Qdrant::from_url("https://xyz-example.eu-central.aws.cloud.qdrant.io:6334")
    .api_key("<paste-your-api-key-here>")
    .build()?;
import io.qdrant.client.QdrantClient;
import io.qdrant.client.QdrantGrpcClient;

QdrantClient client =
    new QdrantClient(
        QdrantGrpcClient.newBuilder(
                "xyz-example.eu-central.aws.cloud.qdrant.io",
                6334,
                true)
            .withApiKey("<paste-your-api-key-here>")
            .build());
using Qdrant.Client;

var client = new QdrantClient(
  host: "xyz-example.eu-central.aws.cloud.qdrant.io",
  https: true,
  apiKey: "<paste-your-api-key-here>"
);
import "github.com/qdrant/go-client/qdrant"

client, err := qdrant.NewClient(&qdrant.Config{
	Host:   "xyz-example.eu-central.aws.cloud.qdrant.io",
	Port:   6334,
	APIKey: "<paste-your-api-key-here>",
	UseTLS: true,
})
这个页面有用吗?

感谢您的反馈!🙏

我们很抱歉听到这个消息。😔 你可以在GitHub上编辑这个页面,或者创建一个GitHub问题。