用途:db9 是面向 AI 智能体的无服务器、兼容 Postgres 的数据库,可在不到一秒内创建数据库,支持通过控制平面 REST API 执行 SQL,或用短期连接令牌通过 Postgres 线协议(pgwire)直连。
主要能力:内置嵌入函数和向量检索(EMBED(...) 与 pgvector 操作符 <=>、<->、<#> 开箱即用,无需外部嵌入 API);支持全文检索;支持数据库分支用于实验;支持角色与令牌。
基本用法:所有请求使用 Bearer 令牌认证,环境变量 DB9_API_KEY 为 128 位十六进制字符串。基础地址 https://api.db9.ai。主要操作为创建/列出/删除数据库、执行 SQL(HTTP 或 pgwire)、创建分支、生成连接令牌(db9ck_…)和可发布密钥(db9pk_…)。示例命令保持原样:curl -s -X POST "https://api.db9.ai/customer/databases" --header "Authorization: Bearer $DB9_API_KEY" --header "Content-Type: application/json" -d @/tmp/db9_create.json;curl -s "https://api.db9.ai/customer/databases" --header "Authorization: Bearer $DB9_API_KEY";curl -s -X POST "https://api.db9.ai/customer/databases/<database-id>/sql" --header "Authorization: Bearer $DB9_API_KEY" --header "Content-Type: application/json" -d @/tmp/db9_sql.json。
适用场景:智能体记忆、语义搜索、需要快速创建和分支的实验、ORM 或 psql 直连。
限制与注意事项:DB9_API_KEY 仅可发送到 api.db9.ai,切勿嵌入客户端代码;浏览器访问应使用可发布密钥(db9pk_…);长期连接或 ORM 集成建议改用 pgwire;破坏性实验建议使用分支。若请求失败,可运行 zero doctor check-connector --env-name DB9_API_KEY 或 zero doctor check-connector --url https://api.db9.ai/customer/databases --method GET。