跳到主要内容

aidy.v2.ext.billing

Messages & Enums

message Adjustment

单条定价调整规则。

message Adjustment {
AdjustmentMode mode = 1;
// 命中条件;多个字段按 AND 组合。
Condition when = 2;
// 排除条件;任一命中则不应用当前 adjustment。
repeated Condition unless = 3;
// 命中后写入或乘算的目标值。
RateCard values = 4;
}

enum AdjustmentMode

调整模式。

enum AdjustmentMode {
ADJUSTMENT_MODE_UNSPECIFIED = 0;
ADJUSTMENT_MODE_ABSOLUTE = 1;
ADJUSTMENT_MODE_MULTIPLIER = 2;
}

message BillingExt

请求级 billing 结果。

message BillingExt {
// 结算状态,例如 settled / settle_failed。
string status = 1;
// 命中的 consumer ID。
string consumer_id = 2;
// 命中的 consumer API key ID;为空时输出 null。
google.protobuf.Value consumer_api_key_id = 3;
// 本次最终扣费的 credit 数。
int32 charged_credit = 4;
// 账本条目 ID 列表;即使为空也保留为空数组。
google.protobuf.ListValue ledger_entry_ids = 5;
// 错误信息;成功时输出 null。
google.protobuf.Value error = 6;
}

message Condition

adjustment 的条件表达式。

message Condition {
string service_tier = 1;
string cache_ttl = 2;
bool thinking_mode = 3;
TokenRange text_total_input = 4;
TokenRange text_output = 5;
}

message Pricing

ProviderPricing.pricing 的定价结构。

message Pricing {
// 基础定价,至少需要提供 text_input 或 text_output 之一。
RateCard base_pricing = 1;
// 条件调整项;运行时当前只消费 base_pricing,
// 但管理面与持久化层统一按完整 schema 校验。
repeated Adjustment adjustments = 2;
}

message RateCard

每 1,000,000 tokens 的 credit 定价表。

message RateCard {
uint32 text_input = 1;
uint32 text_output = 2;
uint32 text_input_cache_read = 3;
uint32 text_input_cache_write = 4;
}

message TokenRange

token 区间;max_inclusive 缺省表示无上界。

message TokenRange {
uint32 min_inclusive = 1;
uint32 max_inclusive = 2;
}