agentbase-docs

限额与配额

这是什么 / 何时用

平台对项目/账号施加两类上限:

前置

使用骨架

关键参数与返回

错误与边界

SDK 类别差异

各语言调用示例

以下按使用骨架逐项给出各语言调用示例;每个卡片可切换语言(全页同步)。

项目配额(Quota)读写

项目级 Quota 四字段读写:读返回 quota / sources / accountLimit / globalLimit,写为部分更新(未传字段不变)。Web SDK 不暴露配额/限频管理,无 Web 页签;项目级 quota 的 typed 方法仅在 console-java Projects(getQuotaLimits(projectId) / updateQuotaLimits(projectId, 四个 quota 字段));server-java / server-python / server-go 的 Projects 均无(源码核验),统一走 REST。

import { Client, Projects } from 'agentbase-node-sdk';

const client = new Client()
    .setEndpoint(process.env.APPBASE_ENDPOINT!)   // 须包含 /v1
    .setProject(process.env.APPBASE_PROJECT_ID!)
    .setKey(process.env.APPBASE_API_KEY!);        // projects.read / projects.write 最小 scope
const projects = new Projects(client);

const quota = await projects.getQuotaLimits({ projectId: '<projectId>' });
// 返回 quota / sources / accountLimit / globalLimit;sources 说明每字段来自项目覆盖、账号 ceiling 还是全局默认
await projects.updateQuotaLimits({ projectId: '<projectId>', tablesPerProject: 120 });
// 部分更新:未传字段不变;0=不限量(需继承的上级 ceiling 允许)
// 账号级:account.getQuotaLimits / updateQuotaLimits / deleteQuotaLimits / listLimitsProjects

账号级配额(Account Quota)

账号级读写 /account/quota-limits,走账号凭据(Console Session/JWT,非项目 API Key):updateQuotaLimits 部分更新四字段,deleteQuotaLimits 删除覆盖回退继承值,listLimitsProjects 列出有项目级覆盖的项目。Web SDK 不暴露配额管理;server-java / console-java 的 Account、server-python account、server-go account 均有账号级 typed 方法(getQuotaLimits / updateQuotaLimits / deleteQuotaLimits 与 listLimitsProjects,源码核验)。

// 账号级走 Console Session/JWT(非项目 API Key)
await sdk.forConsole.account.getQuotaLimits();
await sdk.forConsole.account.updateQuotaLimits({ tablesPerProject: 120 });   // 四 quota 字段部分更新
await sdk.forConsole.account.deleteQuotaLimits();   // 删除覆盖,回退继承值
// listLimitsProjects() 列出设置了项目级覆盖的项目

限频调优(综合 /limits:限频 + 配额)

/limits 一次读写 5 个限频字段 + 4 个配额字段;限频字段必须为正整数(没有 0=不限 语义),响应含 rateLimit / quota / accountLimit / overrides。Web SDK 不暴露配额/限频管理;项目级 /limits 的 typed 方法仅在 console-java Projects(getLimits(projectId) / updateLimits(projectId, 5 个限频字段 + 4 个配额字段) / deleteLimits(projectId, keys));server-java / server-python / server-go 的 Projects 均无(源码核验),统一走 REST(Console 无 typed 封装时用 client.call,见卡内);账号级 /account/limits 在上述三家 Account 均有 getLimits / updateLimits(overrides) / deleteLimits(keys)。

// Node Server SDK 扩展封装:getLimits / updateLimits 走综合 /limits 接口
const limits = await projects.getLimits({ projectId: '<projectId>' });
await projects.updateLimits({
    projectId: '<projectId>',
    projectDefault: 30000, apiKeyDefault: 1200, projectUserDefault: 60,
    consoleDefault: 60, anonymousDefault: 60,
    databaseStorageLimit: 209715200, storageLimit: 209715200,
    databasesPerProject: 5, tablesPerProject: 100
});

示例指引

事实源