aidy.v2.core
Messages
message Consumer
Consumer 表示租户下的调用方主体。
message Consumer { // Consumer ID,格式约定为 cs_<ulid>。 string id = 1; // 所属 tenant_id。 string tenant_id = 2; // 展示名称。 string name = 3; // 调用方状态,当前仅支持 active / disabled。 string status = 4; // 当前剩余 Credit;仅表示余额快照。 int64 remaining_credit = 5; // 仅原样透传给下游,用于存储元信息;不影响 aidy 逻辑。 google.protobuf.Struct metadata = 6; // 资源创建时间。 google.protobuf.Timestamp created_at = 7; // 资源更新时间。 google.protobuf.Timestamp updated_at = 8; // 分组集合,用于与 route / api key / upstream 的组约束求交集。 repeated string groups = 10; // 为 true 时表示该 consumer 不限制额度。 bool unlimited_credit = 11; // 历史累计已用 Credit;仅表示快照。 int64 used_credit = 12;}message ConsumerAPIKey
ConsumerAPIKey 表示租户下调用方的访问凭证。
message ConsumerAPIKey { // API key ID,格式约定为 cak_<ulid>。 string id = 1; // 所属 consumer_id。 string consumer_id = 2; // 明文 key。 string key = 3; // 展示名称。 string name = 4; // 非空表示该 key 已禁用。 google.protobuf.Timestamp disabled_at = 5; // 过期时间。 google.protobuf.Timestamp expires_at = 6; // 当前剩余 Credit;仅表示余额快照。 int64 remaining_credit = 7; // 最近一次被使用的时间。 google.protobuf.Timestamp last_used_at = 8; // 资源创建时间。 google.protobuf.Timestamp created_at = 9; // 资源更新时间。 google.protobuf.Timestamp updated_at = 10; // 所属 tenant_id。 string tenant_id = 11; // 分组集合,用于与 route / consumer / upstream 的组约束求交集。 repeated string groups = 12; // 为 true 时表示该 key 不限制额度。 bool unlimited_credit = 13; // 历史累计已用 Credit;仅表示快照。 int64 used_credit = 14; // 非空表示该 key 已撤销;撤销后不可恢复使用。 google.protobuf.Timestamp revoked_at = 15;}message Provider
可复用的协议与默认连接模板。
message Provider { // Provider ID;global provider 通常使用 gp_ 前缀,tenant provider 使用 tp_ 前缀。 string id = 1; // 来源范围,当前支持 global / tenant。 string source_scope = 2; // 来源引用 ID;global provider 为空字符串,tenant provider 对应 tenant_id。 string source_ref_id = 3; // 展示名称。 string name = 4; // 描述信息。 string description = 5; // 上游协议类型;运行时主要按 protocol + compat 工作。 string protocol = 6; // 默认 base URL;具体是否需要携带 /v1 取决于协议。 string base_url = 7; // 默认静态请求头。 map<string,string> headers = 8; // 协议兼容配置;实际内容对应 aidy.v2.protocol 中对应协议配置的 protojson 序列化,详见 protocol.proto / Protocols。 google.protobuf.Struct compat = 9; // Provider 自检时使用的模型名。 string check_model = 10; // 非空表示当前 provider 已禁用。 google.protobuf.Timestamp disabled_at = 11; // 资源创建时间。 google.protobuf.Timestamp created_at = 12; // 资源更新时间。 google.protobuf.Timestamp updated_at = 13; // Provider 默认 forwarder 能力集合;为空时按 protocol 推导默认值。 repeated string capabilities = 14; // 网关层 request header override DSL;实际内容见「请求 Header 覆盖」文档。 google.protobuf.Struct request_header_overrides = 15;}message ProviderPricing
某个 provider 在某个模型上的计费配置。
message ProviderPricing { // 定价记录 ID,格式约定为 ppr_<ulid>。 string id = 1; // 所属 tenant;global provider 的 pricing 为空字符串。 string tenant_id = 2; // 关联的 provider_id。 string provider_id = 3; // 定价对应的模型名。 string model = 4; // Provider 定价配置;实际内容对应 aidy.v2.ext.billing.Pricing 的 protojson 序列化,详见 billing.proto。 google.protobuf.Struct pricing = 5; // 资源创建时间。 google.protobuf.Timestamp created_at = 6; // 资源更新时间。 google.protobuf.Timestamp updated_at = 7;}message RequestLog
RequestLog 表示管理面查询到的一条请求日志记录。
message RequestLog { // 日志 ID,格式约定为 rql_<ulid>。 string id = 1; // 所属 tenant_id。 string tenant_id = 2; // 命中的 route_id。 string route_id = 3; // 命中的 route_name。 string route_name = 4; // 请求链路中的 request_id。 string request_id = 5; // 客户端请求的模型名。 string requested_model = 6; // 客户端地址。 string remote_addr = 7; // 请求摘要/完整视图对象;实际内容来自 aidy.v2.logging.v1.RequestLog.request 的 protojson 序列化,详见 request_log.proto / 请求日志输出。 google.protobuf.Struct request = 8; // 响应摘要/完整视图对象;实际内容来自 aidy.v2.logging.v1.RequestLog.response 的 protojson 序列化,详见 request_log.proto / 请求日志输出。 google.protobuf.Struct response = 9; // 上游请求数组摘要,按尝试顺序记录。 google.protobuf.ListValue upstream_requests = 10; // 关键时间点对象;实际内容见「计时」文档。 google.protobuf.Struct timing = 12; // 各阶段耗时对象;实际内容见「计时」文档。 google.protobuf.Struct duration = 13; // 最终错误信息;成功请求通常为空。 string error = 14; // 请求日志扩展字段对象;实际内容见「Ext Fields」文档。 google.protobuf.Struct ext_fields = 15; // 日志创建时间。 google.protobuf.Timestamp created_at = 16; // 日志更新时间。 google.protobuf.Timestamp updated_at = 17;}message Route
管理面的路由入口资源。
message Route { // Route ID,格式约定为 rt_<ulid>。 string id = 1; // 所属 tenant_id。 string tenant_id = 2; // 路由名称。 string name = 3; // 路由前缀;管理面当前要求是以 / 开头的简单 path prefix。 string path_prefix = 4; // 是否透传客户端 Authorization 到上游;属于 legacy 兼容字段。 bool passthrough_auth_token = 6; // 路由标签对象;运行时会进入请求日志事件的 route_labels。 google.protobuf.Struct labels = 8; // 仅原样透传给下游,用于存储元信息;不影响 aidy 逻辑。 google.protobuf.Struct metadata = 10; // 资源创建时间。 google.protobuf.Timestamp created_at = 11; // 资源更新时间。 google.protobuf.Timestamp updated_at = 12; // 路由分组约束;与 consumer / api key / upstream group 一起参与选路。 repeated string groups = 14; // 为 true 时直接跳过该 route 的鉴权。 bool disable_auth = 15; // route 级 legacy bearer token 列表。 repeated string legacy_bearer_auth_tokens = 16; // 非空表示当前 route 已禁用。 google.protobuf.Timestamp disabled_at = 17; // 协议转换配置位;当前仍会校验和持久化,但不会切换 chat 主链路行为分支。 string protocol_transformation_type = 18; // 单次请求进入真实转发 / fallback 计划的最大候选数;默认值由服务端补成 2。 int32 max_attempts = 19;}message RoutePluginConfig
route 级插件配置的聚合视图。
message RoutePluginConfig { // 关联的 route_id。 string route_id = 1; // 由 route 推导出的 tenant_id;管理面写请求中不接受客户端指定。 string tenant_id = 2; // 由 route 推导出的 route_name;管理面写请求中不接受客户端指定。 string route_name = 3; // 该 route 当前聚合后的插件配置明细。 // 聚合资源创建时间。 google.protobuf.Timestamp created_at = 5; // 聚合资源更新时间。 google.protobuf.Timestamp updated_at = 6;}message RoutePluginConfigEntry
plugin_configs 表中的单条 route 级配置项。
message RoutePluginConfigEntry { // 关联的 route_id。 string route_id = 1; // 由 route 推导出的 tenant_id;管理面写请求中不接受客户端指定。 string tenant_id = 2; // 插件主键,例如 guard / inbound_rate_limit。 string plugin_key = 3; // 插件子键;用于区分同一插件下的细粒度配置项。 string plugin_sub_key = 4; // 插件配置值,原样存储为 JSON。 google.protobuf.Value config = 5; // 资源创建时间。 google.protobuf.Timestamp created_at = 6; // 资源更新时间。 google.protobuf.Timestamp updated_at = 7;}message Tenant
管理面中的租户资源。
message Tenant { // 租户 ID,格式约定为 tn_<ulid>。 string id = 1; // 租户名称。 string name = 2; // 租户状态,当前仅支持 active / disabled。 string status = 3; // 租户入口限速,单位为每秒请求数;当前仍属于 legacy 兼容字段。 uint32 inbound_rate_limit_qps = 4; // Guard detect 限速,单位为每分钟字符数;当前仍属于 legacy 兼容字段。 uint32 detect_rate_limit_cpm = 5; // 仅原样透传给下游,用于存储元信息;不影响 aidy 逻辑。 google.protobuf.Struct metadata = 6; // 资源创建时间。 google.protobuf.Timestamp created_at = 7; // 资源更新时间。 google.protobuf.Timestamp updated_at = 8;}message Upstream
tenant 下真正参与选路的上游目标。
message Upstream { // Upstream ID,格式约定为 ups_<ulid>。 string id = 1; // 所属 tenant_id。 string tenant_id = 2; // 绑定的 provider_id。 string provider_id = 3; // 上游名称。 string name = 4; // 实际生效的 base URL;为空时由运行时回退到 provider.base_url。 string base_url = 5; // 实际生效的静态请求头。 map<string,string> headers = 6; // 实际生效的协议兼容配置;内容对应 aidy.v2.protocol 中对应协议配置的 protojson 序列化,详见 protocol.proto / Protocols。 google.protobuf.Struct compat = 7; // 当前内嵌在 upstream 中的 API key 列表;底层已不是独立表。 // 每个 host 允许保留的空闲连接数。 int32 max_idle_conns_per_host = 10; // 同优先级内的默认负载均衡权重。 int32 lb_weight = 11; // 选路优先级;数值越大优先级越高。 int32 priority = 12; // Upstream 自检时使用的模型名。 string check_model = 13; // 非空表示当前 upstream 已禁用。 google.protobuf.Timestamp disabled_at = 14; // 资源创建时间。 google.protobuf.Timestamp created_at = 15; // 资源更新时间。 google.protobuf.Timestamp updated_at = 16; // 上游所属分组;服务端默认会补成 default。 string group = 18; // Upstream 能力覆盖;非空时完整覆盖 provider.capabilities,空时继承 provider。 repeated string capabilities = 19; // Upstream 侧 request header override DSL;实际内容见「请求 Header 覆盖」文档。 google.protobuf.Struct request_header_overrides = 20;}message UpstreamAPIKey
内嵌在 upstream 中的一条凭证配置。
message UpstreamAPIKey { // API key ID,格式约定为 uak_<ulid>。 string id = 1; // 所属 upstream_id。 string upstream_id = 2; // 展示名称。 string name = 3; // 明文 key。 string key = 4; // 该 key 自身的优先级;在候选展开后继承到具体候选。 int32 priority = 5; // 该 key 自身的负载均衡权重;为空效果时回退到 upstream.lb_weight。 int32 lb_weight = 6; // 非空表示该 key 已禁用。 google.protobuf.Timestamp disabled_at = 7; // 过期时间。 google.protobuf.Timestamp expires_at = 8; // 最近一次被使用的时间。 google.protobuf.Timestamp last_used_at = 9; // 仅原样透传给下游,用于存储元信息;不影响 aidy 逻辑。 google.protobuf.Struct metadata = 10; // 资源创建时间。 google.protobuf.Timestamp created_at = 11; // 资源更新时间。 google.protobuf.Timestamp updated_at = 12; // 所属 tenant_id。 string tenant_id = 13;}message UpstreamModel
UpstreamModel 表示客户端模型名到具体 upstream 模型名的映射。
message UpstreamModel { // 展示用 ID;真实定位键是 (upstream_id, model)。 string id = 1; // 所属 upstream_id。 string upstream_id = 2; // 客户端可见的模型名。 string model = 3; // 为 true 表示该记录是 alias 行。 bool is_alias = 4; // 实际发往上游的模型名。 string upstream_model = 5; // 资源创建时间。 google.protobuf.Timestamp created_at = 10; // 资源更新时间。 google.protobuf.Timestamp updated_at = 11; // 所属 tenant_id。 string tenant_id = 12;}