mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-09 03:02:26 +08:00
feat: 所有计费模板支持按次计费,调整端点默认重试次数为 2
- 为 Claude、OpenAI、豆包、Gemini 计费模板添加 request 维度 - 支持通过 price_per_request 配置按次计费(如图片生成模型) - 将端点 max_retries 默认值从 3 改为 2(请求一次 + 重试一次)
This commit is contained in:
@@ -597,7 +597,7 @@ class ProviderEndpoint(Base):
|
||||
# 请求配置
|
||||
headers = Column(JSON, nullable=True) # 额外请求头
|
||||
timeout = Column(Integer, default=300) # 超时(秒)
|
||||
max_retries = Column(Integer, default=3) # 最大重试次数
|
||||
max_retries = Column(Integer, default=2) # 最大重试次数
|
||||
|
||||
# 限制
|
||||
max_concurrent = Column(
|
||||
|
||||
@@ -24,7 +24,7 @@ class ProviderEndpointCreate(BaseModel):
|
||||
# 请求配置
|
||||
headers: Optional[Dict[str, str]] = Field(default=None, description="自定义请求头")
|
||||
timeout: int = Field(default=300, ge=10, le=600, description="超时时间(秒)")
|
||||
max_retries: int = Field(default=3, ge=0, le=10, description="最大重试次数")
|
||||
max_retries: int = Field(default=2, ge=0, le=10, description="最大重试次数")
|
||||
|
||||
# 限制
|
||||
max_concurrent: Optional[int] = Field(default=None, ge=1, description="最大并发数")
|
||||
|
||||
@@ -23,6 +23,7 @@ class BillingTemplates:
|
||||
# - 输出 token
|
||||
# - 缓存创建(创建时收费,约 1.25x 输入价格)
|
||||
# - 缓存读取(约 0.1x 输入价格)
|
||||
# - 按次计费(可选,配置 price_per_request 时生效)
|
||||
# =========================================================================
|
||||
CLAUDE_STANDARD: List[BillingDimension] = [
|
||||
BillingDimension(
|
||||
@@ -45,6 +46,12 @@ class BillingTemplates:
|
||||
usage_field="cache_read_tokens",
|
||||
price_field="cache_read_price_per_1m",
|
||||
),
|
||||
BillingDimension(
|
||||
name="request",
|
||||
usage_field="request_count",
|
||||
price_field="price_per_request",
|
||||
unit=BillingUnit.PER_REQUEST,
|
||||
),
|
||||
]
|
||||
|
||||
# =========================================================================
|
||||
@@ -52,6 +59,7 @@ class BillingTemplates:
|
||||
# - 输入 token
|
||||
# - 输出 token
|
||||
# - 缓存读取(部分模型支持,无缓存创建费用)
|
||||
# - 按次计费(可选,配置 price_per_request 时生效)
|
||||
# =========================================================================
|
||||
OPENAI_STANDARD: List[BillingDimension] = [
|
||||
BillingDimension(
|
||||
@@ -69,6 +77,12 @@ class BillingTemplates:
|
||||
usage_field="cache_read_tokens",
|
||||
price_field="cache_read_price_per_1m",
|
||||
),
|
||||
BillingDimension(
|
||||
name="request",
|
||||
usage_field="request_count",
|
||||
price_field="price_per_request",
|
||||
unit=BillingUnit.PER_REQUEST,
|
||||
),
|
||||
]
|
||||
|
||||
# =========================================================================
|
||||
@@ -77,6 +91,7 @@ class BillingTemplates:
|
||||
# - 推理输出 (output_tokens)
|
||||
# - 缓存命中 (cache_read_tokens) - 类似 Claude 的缓存读取
|
||||
# - 缓存存储 (cache_storage_token_hours) - 按 token 数 * 存储时长计费
|
||||
# - 按次计费(可选,配置 price_per_request 时生效)
|
||||
#
|
||||
# 注意:豆包的缓存创建是免费的,但存储需要按时付费
|
||||
# =========================================================================
|
||||
@@ -102,6 +117,12 @@ class BillingTemplates:
|
||||
price_field="cache_storage_price_per_1m_hour",
|
||||
unit=BillingUnit.PER_1M_TOKENS_HOUR,
|
||||
),
|
||||
BillingDimension(
|
||||
name="request",
|
||||
usage_field="request_count",
|
||||
price_field="price_per_request",
|
||||
unit=BillingUnit.PER_REQUEST,
|
||||
),
|
||||
]
|
||||
|
||||
# =========================================================================
|
||||
@@ -109,6 +130,7 @@ class BillingTemplates:
|
||||
# - 输入 token
|
||||
# - 输出 token
|
||||
# - 缓存读取
|
||||
# - 按次计费(用于图片生成等模型,需配置 price_per_request)
|
||||
# =========================================================================
|
||||
GEMINI_STANDARD: List[BillingDimension] = [
|
||||
BillingDimension(
|
||||
@@ -126,6 +148,12 @@ class BillingTemplates:
|
||||
usage_field="cache_read_tokens",
|
||||
price_field="cache_read_price_per_1m",
|
||||
),
|
||||
BillingDimension(
|
||||
name="request",
|
||||
usage_field="request_count",
|
||||
price_field="price_per_request",
|
||||
unit=BillingUnit.PER_REQUEST,
|
||||
),
|
||||
]
|
||||
|
||||
# =========================================================================
|
||||
|
||||
Reference in New Issue
Block a user