VisibleBase
快速开始

连接 client

在产品侧使用 UserClient 调用 Base。

产品侧使用 UserClient。它需要 base_urlproduct_iduser_token

import { UserClient } from "@visiblebase/client";

const client = new UserClient({
  base_url: "https://base.example.com",
  product_id: "prod_xxx",
  user_token: "ub_xxx",
});

const models = await client.models();

const result = await client.text({
  model: models.primary(),
  prompt: "写一段产品欢迎语",
});

如果你已经知道具体模型,也可以用目录选择:

const body = await client.stream({
  model: models("gpt-5.4"),
  prompt: "流式输出一段文案",
});

text() 返回 AI SDK UIMessagestream() 返回 ReadableStream<UIMessageChunk>,前提是 Base 侧的 stream handler 返回 AI SDK UIMessage stream response。

同一个 Base 可以服务多个 client:

  • https://app.example.com
  • Chrome 插件
  • 桌面工具
  • 移动端
  • 内部运营工具

这些 client 不需要各自维护 provider key、模型路由和 usage 记录。