coding-proxy 0.1.4a8__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,12 +26,12 @@ logging:
26
26
  # 示例 3:将 zhipu 提升为首选,anthropic 作为后备
27
27
  # tiers: ["zhipu", "anthropic"]
28
28
 
29
- tiers: ["anthropic", "copilot", "antigravity", "zhipu"]
29
+ tiers: ["zhipu", "anthropic", "copilot", "antigravity"]
30
30
 
31
31
  # === 供应商定义(vendors 列表) ===
32
32
  #
33
33
  # 每个 vendor 通过 vendor 字段指定供应商类型:
34
- # anthropic | copilot | antigravity | zhipu
34
+ # anthropic | zhipu | minimax | alibaba | xiaomi | kimi | doubao | copilot | antigravity
35
35
  #
36
36
  # 优先级规则:
37
37
  # - 若配置了 tiers,以其指定的顺序为准
@@ -101,6 +101,7 @@ vendors:
101
101
 
102
102
  # Vendor 3: 智谱 GLM(终端兜底,无 circuit_breaker)
103
103
  - vendor: zhipu
104
+ enabled: true
104
105
  base_url: "https://open.bigmodel.cn/api/anthropic"
105
106
  api_key: "${ZHIPU_API_KEY}"
106
107
  timeout_ms: 3000000
@@ -116,6 +117,91 @@ vendors:
116
117
  threshold_percent: 95.0
117
118
  probe_interval_seconds: 300
118
119
 
120
+ # Vendor 4: MiniMax(默认禁用,需手动启用并添加到 tiers)
121
+ - vendor: minimax
122
+ enabled: false
123
+ base_url: "https://api.minimaxi.com/anthropic"
124
+ api_key: "${MINIMAX_API_KEY}"
125
+ timeout_ms: 3000000
126
+ circuit_breaker:
127
+ failure_threshold: 3
128
+ recovery_timeout_seconds: 300
129
+ success_threshold: 2
130
+ quota_guard:
131
+ enabled: false
132
+ token_budget: 1000000000
133
+ window_hours: 24.0
134
+ threshold_percent: 95.0
135
+ probe_interval_seconds: 300
136
+
137
+ # Vendor 5: 阿里 Qwen(默认禁用)
138
+ - vendor: alibaba
139
+ enabled: false
140
+ base_url: "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic"
141
+ api_key: "${ALIBABA_API_KEY}"
142
+ timeout_ms: 3000000
143
+ circuit_breaker:
144
+ failure_threshold: 3
145
+ recovery_timeout_seconds: 300
146
+ success_threshold: 2
147
+ quota_guard:
148
+ enabled: false
149
+ token_budget: 1000000000
150
+ window_hours: 24.0
151
+ threshold_percent: 95.0
152
+ probe_interval_seconds: 300
153
+
154
+ # Vendor 6: 小米 MiMo(默认禁用)
155
+ - vendor: xiaomi
156
+ enabled: false
157
+ base_url: "https://token-plan-cn.xiaomimimo.com/anthropic"
158
+ api_key: "${XIAOMI_API_KEY}"
159
+ timeout_ms: 3000000
160
+ circuit_breaker:
161
+ failure_threshold: 3
162
+ recovery_timeout_seconds: 300
163
+ success_threshold: 2
164
+ quota_guard:
165
+ enabled: false
166
+ token_budget: 1000000000
167
+ window_hours: 24.0
168
+ threshold_percent: 95.0
169
+ probe_interval_seconds: 300
170
+
171
+ # Vendor 7: Kimi(默认禁用)
172
+ - vendor: kimi
173
+ enabled: false
174
+ base_url: "https://api.kimi.com/coding/"
175
+ api_key: "${KIMI_API_KEY}"
176
+ timeout_ms: 3000000
177
+ circuit_breaker:
178
+ failure_threshold: 3
179
+ recovery_timeout_seconds: 300
180
+ success_threshold: 2
181
+ quota_guard:
182
+ enabled: false
183
+ token_budget: 1000000000
184
+ window_hours: 24.0
185
+ threshold_percent: 95.0
186
+ probe_interval_seconds: 300
187
+
188
+ # Vendor 8: 豆包 Doubao(默认禁用)
189
+ - vendor: doubao
190
+ enabled: false
191
+ base_url: "https://ark.cn-beijing.volces.com/api/coding"
192
+ api_key: "${ARK_API_KEY}"
193
+ timeout_ms: 3000000
194
+ circuit_breaker:
195
+ failure_threshold: 3
196
+ recovery_timeout_seconds: 300
197
+ success_threshold: 2
198
+ quota_guard:
199
+ enabled: false
200
+ token_budget: 1000000000
201
+ window_hours: 24.0
202
+ threshold_percent: 95.0
203
+ probe_interval_seconds: 300
204
+
119
205
  # === 故障转移触发条件 ===
120
206
  failover:
121
207
  status_codes: [429, 403, 503, 500, 529]
@@ -166,6 +252,71 @@ model_mapping:
166
252
  vendors: ["zhipu"]
167
253
  target: "glm-4.5-air"
168
254
  is_regex: true
255
+ # MiniMax 模型映射(原生 Anthropic 兼容端点)
256
+ - pattern: "claude-sonnet-.*"
257
+ vendors: ["minimax"]
258
+ target: "minimax-m2.7"
259
+ is_regex: true
260
+ - pattern: "claude-opus-.*"
261
+ vendors: ["minimax"]
262
+ target: "minimax-m2.7"
263
+ is_regex: true
264
+ - pattern: "claude-haiku-.*"
265
+ vendors: ["minimax"]
266
+ target: "minimax-m2.7"
267
+ is_regex: true
268
+ # 阿里 Qwen 模型映射(原生 Anthropic 兼容端点)
269
+ - pattern: "claude-sonnet-.*"
270
+ vendors: ["alibaba"]
271
+ target: "qwen3.6-plus"
272
+ is_regex: true
273
+ - pattern: "claude-opus-.*"
274
+ vendors: ["alibaba"]
275
+ target: "qwen3.6-plus"
276
+ is_regex: true
277
+ - pattern: "claude-haiku-.*"
278
+ vendors: ["alibaba"]
279
+ target: "qwen3.6-plus"
280
+ is_regex: true
281
+ # 小米 MiMo 模型映射(原生 Anthropic 兼容端点)
282
+ - pattern: "claude-sonnet-.*"
283
+ vendors: ["xiaomi"]
284
+ target: "mimo-v2-pro"
285
+ is_regex: true
286
+ - pattern: "claude-opus-.*"
287
+ vendors: ["xiaomi"]
288
+ target: "mimo-v2-pro"
289
+ is_regex: true
290
+ - pattern: "claude-haiku-.*"
291
+ vendors: ["xiaomi"]
292
+ target: "mimo-v2-pro"
293
+ is_regex: true
294
+ # Kimi 模型映射(原生 Anthropic 兼容端点)
295
+ - pattern: "claude-sonnet-.*"
296
+ vendors: ["kimi"]
297
+ target: "kimi-k2.5"
298
+ is_regex: true
299
+ - pattern: "claude-opus-.*"
300
+ vendors: ["kimi"]
301
+ target: "kimi-k2.5"
302
+ is_regex: true
303
+ - pattern: "claude-haiku-.*"
304
+ vendors: ["kimi"]
305
+ target: "kimi-k2.5"
306
+ is_regex: true
307
+ # 豆包 Doubao 模型映射(三个不同模型对应不同 Claude 模型槽位)
308
+ - pattern: "claude-opus-.*"
309
+ vendors: ["doubao"]
310
+ target: "doubao-seed-2.0-code"
311
+ is_regex: true
312
+ - pattern: "claude-sonnet-.*"
313
+ vendors: ["doubao"]
314
+ target: "doubao-seed-2.0-pro"
315
+ is_regex: true
316
+ - pattern: "claude-haiku-.*"
317
+ vendors: ["doubao"]
318
+ target: "doubao-seed-2.0-lite"
319
+ is_regex: true
169
320
 
170
321
  # === 模型定价(USD / 1M tokens) ===
171
322
  # vendor: 供应商名称(对应 `usage` 统计表中的"供应商"列)
@@ -271,6 +422,64 @@ pricing:
271
422
  input_cost_per_mtok: ¥4.00
272
423
  output_cost_per_mtok: ¥18.00
273
424
  cache_read_cost_per_mtok: ¥1.00
425
+ # ── MiniMax ──
426
+ - vendor: minimax
427
+ model: minimax-m2.7
428
+ input_cost_per_mtok: ¥2.10
429
+ output_cost_per_mtok: ¥8.40
430
+ cache_write_cost_per_mtok: ¥2.625
431
+ cache_read_cost_per_mtok: ¥0.42
432
+ - vendor: minimax
433
+ model: minimax-m2.5
434
+ input_cost_per_mtok: ¥2.10
435
+ output_cost_per_mtok: ¥8.40
436
+ cache_write_cost_per_mtok: ¥2.625
437
+ cache_read_cost_per_mtok: ¥0.21
438
+ # ── 阿里 Qwen ──
439
+ - vendor: alibaba
440
+ model: qwen3.6-plus
441
+ input_cost_per_mtok: $0.276
442
+ output_cost_per_mtok: $1.651
443
+ # ── 小米 MiMo ──
444
+ - vendor: xiaomi
445
+ model: mimo-v2-pro
446
+ input_cost_per_mtok: ¥7.00
447
+ output_cost_per_mtok: ¥21.00
448
+ cache_read_cost_per_mtok: ¥1.40
449
+ - vendor: xiaomi
450
+ model: mimo-v2-omni
451
+ input_cost_per_mtok: ¥2.80
452
+ output_cost_per_mtok: ¥14.00
453
+ cache_read_cost_per_mtok: ¥0.56
454
+ - vendor: xiaomi
455
+ model: mimo-v2-flash
456
+ input_cost_per_mtok: ¥0.70
457
+ output_cost_per_mtok: ¥2.10
458
+ cache_read_cost_per_mtok: ¥0.07
459
+ # ── Kimi ──
460
+ - vendor: kimi
461
+ model: kimi-k2.5
462
+ input_cost_per_mtok: $0.60
463
+ output_cost_per_mtok: $3.00
464
+ # ── 豆包 Doubao ──
465
+ - vendor: doubao
466
+ model: doubao-seed-2.0-code
467
+ input_cost_per_mtok: ¥3.20
468
+ output_cost_per_mtok: ¥16.00
469
+ cache_write_cost_per_mtok: ¥0.64
470
+ cache_read_cost_per_mtok: ¥0.017
471
+ - vendor: doubao
472
+ model: doubao-seed-2.0-pro
473
+ input_cost_per_mtok: ¥3.20
474
+ output_cost_per_mtok: ¥16.00
475
+ cache_write_cost_per_mtok: ¥0.64
476
+ cache_read_cost_per_mtok: ¥0.017
477
+ - vendor: doubao
478
+ model: doubao-seed-2.0-lite
479
+ input_cost_per_mtok: ¥0.60
480
+ output_cost_per_mtok: ¥3.60
481
+ cache_write_cost_per_mtok: ¥0.12
482
+ cache_read_cost_per_mtok: ¥0.017
274
483
 
275
484
  database:
276
485
  path: "~/.coding-proxy/usage.db"
@@ -59,19 +59,36 @@ _ANTIGRAVITY_FIELDS: frozenset[str] = frozenset(
59
59
  "model_endpoint",
60
60
  }
61
61
  )
62
- _ZHIPU_FIELDS: frozenset[str] = frozenset(
62
+ _NATIVE_ANTHROPIC_FIELDS: frozenset[str] = frozenset(
63
63
  {
64
64
  "api_key",
65
65
  }
66
66
  )
67
+ # 向后兼容别名
68
+ _ZHIPU_FIELDS = _NATIVE_ANTHROPIC_FIELDS
67
69
 
68
70
  _VENDOR_EXCLUSIVE_FIELDS: dict[str, frozenset[str]] = {
69
71
  "copilot": _COPILOT_FIELDS,
70
72
  "antigravity": _ANTIGRAVITY_FIELDS,
71
- "zhipu": _ZHIPU_FIELDS,
73
+ "zhipu": _NATIVE_ANTHROPIC_FIELDS,
74
+ "minimax": _NATIVE_ANTHROPIC_FIELDS,
75
+ "kimi": _NATIVE_ANTHROPIC_FIELDS,
76
+ "doubao": _NATIVE_ANTHROPIC_FIELDS,
77
+ "xiaomi": _NATIVE_ANTHROPIC_FIELDS,
78
+ "alibaba": _NATIVE_ANTHROPIC_FIELDS,
72
79
  }
73
80
 
74
- VendorType = Literal["anthropic", "copilot", "antigravity", "zhipu"]
81
+ VendorType = Literal[
82
+ "anthropic",
83
+ "copilot",
84
+ "antigravity",
85
+ "zhipu",
86
+ "minimax",
87
+ "kimi",
88
+ "doubao",
89
+ "xiaomi",
90
+ "alibaba",
91
+ ]
75
92
 
76
93
 
77
94
  class ModelMappingRule(BaseModel):
@@ -253,10 +270,10 @@ class VendorConfig(BaseModel):
253
270
  description="[antigravity] Antigravity 模型端点路径",
254
271
  )
255
272
 
256
- # ── Zhipu 专属字段 ────────────────────────────────────────────
273
+ # ── 原生 Anthropic 兼容供应商共用字段 ────────────────────────────
257
274
  api_key: str = Field(
258
275
  default="",
259
- description="[zhipu] 智谱 GLM API Key",
276
+ description="[zhipu/minimax/kimi/doubao/xiaomi/alibaba] 原生 Anthropic 兼容端点 API Key",
260
277
  )
261
278
 
262
279
  # ── 弹性配置 ──────────────────────────────────────────────
@@ -278,6 +295,8 @@ class VendorConfig(BaseModel):
278
295
  if vendor_type == self.vendor:
279
296
  continue
280
297
  for field_name in fields:
298
+ if field_name in exclusive:
299
+ continue
281
300
  value = getattr(self, field_name, None)
282
301
  if value and value != getattr(
283
302
  VendorConfig.model_fields[field_name], "default", None
@@ -307,6 +326,7 @@ __all__ = [
307
326
  "_COPILOT_FIELDS",
308
327
  "_ANTIGRAVITY_FIELDS",
309
328
  "_ZHIPU_FIELDS",
329
+ "_NATIVE_ANTHROPIC_FIELDS",
310
330
  "_VENDOR_EXCLUSIVE_FIELDS",
311
331
  "_BACKEND_EXCLUSIVE_FIELDS",
312
332
  ]
@@ -30,6 +30,7 @@ from .routing import ( # noqa: F401
30
30
  _ANTIGRAVITY_FIELDS,
31
31
  _BACKEND_EXCLUSIVE_FIELDS, # 向后兼容别名
32
32
  _COPILOT_FIELDS,
33
+ _NATIVE_ANTHROPIC_FIELDS,
33
34
  _VENDOR_EXCLUSIVE_FIELDS,
34
35
  _ZHIPU_FIELDS,
35
36
  BackendType, # 向后兼容别名
@@ -43,9 +44,14 @@ from .routing import ( # noqa: F401
43
44
  # ── 子模块 re-export ────────────────────────────────────────────
44
45
  from .server import DatabaseConfig, LoggingConfig, ServerConfig # noqa: F401
45
46
  from .vendors import ( # noqa: F401
47
+ AlibabaConfig,
46
48
  AnthropicConfig,
47
49
  AntigravityConfig,
48
50
  CopilotConfig,
51
+ DoubaoConfig,
52
+ KimiConfig,
53
+ MinimaxConfig,
54
+ XiaomiConfig,
49
55
  ZhipuConfig,
50
56
  )
51
57
 
@@ -303,8 +309,15 @@ __all__ = [
303
309
  "_COPILOT_FIELDS",
304
310
  "_ANTIGRAVITY_FIELDS",
305
311
  "_ZHIPU_FIELDS",
312
+ "_NATIVE_ANTHROPIC_FIELDS",
306
313
  "_VENDOR_EXCLUSIVE_FIELDS",
307
314
  "_BACKEND_EXCLUSIVE_FIELDS",
308
315
  # auth
309
316
  "AuthConfig",
317
+ # new native anthropic vendor configs
318
+ "MinimaxConfig",
319
+ "KimiConfig",
320
+ "DoubaoConfig",
321
+ "XiaomiConfig",
322
+ "AlibabaConfig",
310
323
  ]
@@ -49,9 +49,59 @@ class ZhipuConfig(BaseModel):
49
49
  timeout_ms: int = 3000000
50
50
 
51
51
 
52
+ class MinimaxConfig(BaseModel):
53
+ """MiniMax 供应商配置(原生 Anthropic 兼容端点)."""
54
+
55
+ enabled: bool = True
56
+ base_url: str = "https://api.minimaxi.com/anthropic"
57
+ api_key: str = ""
58
+ timeout_ms: int = 3000000
59
+
60
+
61
+ class KimiConfig(BaseModel):
62
+ """Kimi 供应商配置(原生 Anthropic 兼容端点)."""
63
+
64
+ enabled: bool = True
65
+ base_url: str = "https://api.kimi.com/coding/"
66
+ api_key: str = ""
67
+ timeout_ms: int = 3000000
68
+
69
+
70
+ class DoubaoConfig(BaseModel):
71
+ """豆包 Doubao 供应商配置(原生 Anthropic 兼容端点)."""
72
+
73
+ enabled: bool = True
74
+ base_url: str = "https://ark.cn-beijing.volces.com/api/coding"
75
+ api_key: str = ""
76
+ timeout_ms: int = 3000000
77
+
78
+
79
+ class XiaomiConfig(BaseModel):
80
+ """小米 MiMo 供应商配置(原生 Anthropic 兼容端点)."""
81
+
82
+ enabled: bool = True
83
+ base_url: str = "https://token-plan-cn.xiaomimimo.com/anthropic"
84
+ api_key: str = ""
85
+ timeout_ms: int = 3000000
86
+
87
+
88
+ class AlibabaConfig(BaseModel):
89
+ """阿里 Qwen 供应商配置(原生 Anthropic 兼容端点)."""
90
+
91
+ enabled: bool = True
92
+ base_url: str = "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic"
93
+ api_key: str = ""
94
+ timeout_ms: int = 3000000
95
+
96
+
52
97
  __all__ = [
53
98
  "AnthropicConfig",
54
99
  "CopilotConfig",
55
100
  "AntigravityConfig",
56
101
  "ZhipuConfig",
102
+ "MinimaxConfig",
103
+ "KimiConfig",
104
+ "DoubaoConfig",
105
+ "XiaomiConfig",
106
+ "AlibabaConfig",
57
107
  ]
@@ -168,6 +168,11 @@ def _log_vendor_response_error(
168
168
  _VENDOR_PROTOCOL_LABEL_MAP: dict[str, str] = {
169
169
  "anthropic": "Anthropic",
170
170
  "zhipu": "Anthropic",
171
+ "minimax": "Anthropic",
172
+ "kimi": "Anthropic",
173
+ "doubao": "Anthropic",
174
+ "xiaomi": "Anthropic",
175
+ "alibaba": "Anthropic",
171
176
  "copilot": "OpenAI",
172
177
  "antigravity": "Gemini",
173
178
  }
@@ -16,6 +16,11 @@ _VENDOR_ALIASES = {
16
16
  "fallback": "fallback",
17
17
  "antigravity": "antigravity",
18
18
  "copilot": "copilot",
19
+ "minimax": "minimax",
20
+ "kimi": "kimi",
21
+ "doubao": "doubao",
22
+ "xiaomi": "xiaomi",
23
+ "alibaba": "alibaba",
19
24
  }
20
25
 
21
26
 
@@ -129,7 +129,7 @@ class QuotaGuard:
129
129
  int(self._effective_probe_interval),
130
130
  )
131
131
 
132
- def load_baseline(self, total_tokens: int) -> None:
132
+ def load_baseline(self, total_tokens: int, vendor: str | None = None) -> None:
133
133
  """从数据库加载窗口历史用量基线."""
134
134
  if not self._enabled or total_tokens <= 0:
135
135
  return
@@ -137,7 +137,14 @@ class QuotaGuard:
137
137
  midpoint = time.monotonic() - self._window / 2
138
138
  self._entries.append((midpoint, total_tokens))
139
139
  self._total += total_tokens
140
- logger.info("Quota guard: loaded baseline %d tokens", total_tokens)
140
+ if vendor:
141
+ logger.info(
142
+ "Quota guard [%s]: loaded baseline %d tokens",
143
+ vendor,
144
+ total_tokens,
145
+ )
146
+ else:
147
+ logger.info("Quota guard: loaded baseline %d tokens", total_tokens)
141
148
 
142
149
  def reset(self) -> None:
143
150
  """手动重置为 WITHIN_QUOTA 状态."""
@@ -39,6 +39,11 @@ class RouteSessionManager:
39
39
  "copilot": "openai_chat_completions",
40
40
  "antigravity": "gemini_generate_content",
41
41
  "zhipu": "anthropic_messages",
42
+ "minimax": "anthropic_messages",
43
+ "kimi": "anthropic_messages",
44
+ "doubao": "anthropic_messages",
45
+ "xiaomi": "anthropic_messages",
46
+ "alibaba": "anthropic_messages",
42
47
  "anthropic": "anthropic_messages",
43
48
  }.get(tier.name, "unknown")
44
49
  compat_trace = CompatibilityTrace(
@@ -60,17 +60,14 @@ async def lifespan(app: FastAPI):
60
60
  tier.quota_guard.window_hours,
61
61
  vendor=tier.name,
62
62
  )
63
- tier.quota_guard.load_baseline(total)
63
+ tier.quota_guard.load_baseline(total, vendor=tier.name)
64
64
  if tier.weekly_quota_guard and tier.weekly_quota_guard.enabled:
65
65
  total = await token_logger.query_window_total(
66
66
  tier.weekly_quota_guard.window_hours,
67
67
  vendor=tier.name,
68
68
  )
69
- tier.weekly_quota_guard.load_baseline(total)
69
+ tier.weekly_quota_guard.load_baseline(total, vendor=tier.name)
70
70
 
71
- logger.info(
72
- "coding-proxy started: host=%s port=%d", config.server.host, config.server.port
73
- )
74
71
  yield
75
72
  await router.close()
76
73
  await compat_session_store.close()
@@ -19,23 +19,33 @@ from ..auth.providers.google import (
19
19
  )
20
20
  from ..auth.store import TokenStoreManager
21
21
  from ..config.schema import (
22
+ AlibabaConfig,
22
23
  AnthropicConfig,
23
24
  AntigravityConfig,
24
25
  CircuitBreakerConfig,
25
26
  CopilotConfig,
27
+ DoubaoConfig,
26
28
  FailoverConfig,
29
+ KimiConfig,
30
+ MinimaxConfig,
27
31
  QuotaGuardConfig,
28
32
  TierConfig,
33
+ XiaomiConfig,
29
34
  ZhipuConfig,
30
35
  )
31
36
  from ..routing.circuit_breaker import CircuitBreaker
32
37
  from ..routing.model_mapper import ModelMapper
33
38
  from ..routing.quota_guard import QuotaGuard
34
39
  from ..routing.tier import VendorTier
40
+ from ..vendors.alibaba import AlibabaVendor
35
41
  from ..vendors.anthropic import AnthropicVendor
36
42
  from ..vendors.antigravity import AntigravityVendor
37
43
  from ..vendors.base import BaseVendor
38
44
  from ..vendors.copilot import CopilotVendor
45
+ from ..vendors.doubao import DoubaoVendor
46
+ from ..vendors.kimi import KimiVendor
47
+ from ..vendors.minimax import MinimaxVendor
48
+ from ..vendors.xiaomi import XiaomiVendor
39
49
  from ..vendors.zhipu import ZhipuVendor
40
50
 
41
51
  # 向后兼容别名
@@ -151,6 +161,49 @@ def _create_vendor_from_config(
151
161
  timeout_ms=vendor_cfg.timeout_ms,
152
162
  )
153
163
  return ZhipuVendor(cfg, mapper, failover_cfg)
164
+ case "minimax":
165
+ cfg = MinimaxConfig(
166
+ enabled=vendor_cfg.enabled,
167
+ base_url=vendor_cfg.base_url or "https://api.minimaxi.com/anthropic",
168
+ api_key=vendor_cfg.api_key,
169
+ timeout_ms=vendor_cfg.timeout_ms,
170
+ )
171
+ return MinimaxVendor(cfg, mapper, failover_cfg)
172
+ case "kimi":
173
+ cfg = KimiConfig(
174
+ enabled=vendor_cfg.enabled,
175
+ base_url=vendor_cfg.base_url or "https://api.kimi.com/coding/",
176
+ api_key=vendor_cfg.api_key,
177
+ timeout_ms=vendor_cfg.timeout_ms,
178
+ )
179
+ return KimiVendor(cfg, mapper, failover_cfg)
180
+ case "doubao":
181
+ cfg = DoubaoConfig(
182
+ enabled=vendor_cfg.enabled,
183
+ base_url=vendor_cfg.base_url
184
+ or "https://ark.cn-beijing.volces.com/api/coding",
185
+ api_key=vendor_cfg.api_key,
186
+ timeout_ms=vendor_cfg.timeout_ms,
187
+ )
188
+ return DoubaoVendor(cfg, mapper, failover_cfg)
189
+ case "xiaomi":
190
+ cfg = XiaomiConfig(
191
+ enabled=vendor_cfg.enabled,
192
+ base_url=vendor_cfg.base_url
193
+ or "https://token-plan-cn.xiaomimimo.com/anthropic",
194
+ api_key=vendor_cfg.api_key,
195
+ timeout_ms=vendor_cfg.timeout_ms,
196
+ )
197
+ return XiaomiVendor(cfg, mapper, failover_cfg)
198
+ case "alibaba":
199
+ cfg = AlibabaConfig(
200
+ enabled=vendor_cfg.enabled,
201
+ base_url=vendor_cfg.base_url
202
+ or "https://coding-intl.dashscope.aliyuncs.com/apps/anthropic",
203
+ api_key=vendor_cfg.api_key,
204
+ timeout_ms=vendor_cfg.timeout_ms,
205
+ )
206
+ return AlibabaVendor(cfg, mapper, failover_cfg)
154
207
  case _:
155
208
  raise ValueError(f"未知的 vendor 类型: {vendor_cfg.vendor!r}")
156
209
 
@@ -0,0 +1,27 @@
1
+ """阿里 Qwen 供应商 — 原生 Anthropic 兼容端点薄透传代理.
2
+
3
+ 端点 (https://coding-intl.dashscope.aliyuncs.com/apps/anthropic) 已完整支持
4
+ Anthropic Messages API 协议,仅做模型名映射和认证头替换。
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from ..config.schema import FailoverConfig
10
+ from ..config.vendors import AlibabaConfig
11
+ from ..routing.model_mapper import ModelMapper
12
+ from .native_anthropic import NativeAnthropicVendor
13
+
14
+
15
+ class AlibabaVendor(NativeAnthropicVendor):
16
+ """阿里 Qwen 原生 Anthropic 兼容端点供应商(薄透传)."""
17
+
18
+ _vendor_name = "alibaba"
19
+ _display_name = "Alibaba"
20
+
21
+ def __init__(
22
+ self,
23
+ config: AlibabaConfig,
24
+ model_mapper: ModelMapper,
25
+ failover_config: FailoverConfig | None = None,
26
+ ) -> None:
27
+ super().__init__(config, model_mapper, failover_config)
@@ -0,0 +1,27 @@
1
+ """豆包 Doubao 供应商 — 原生 Anthropic 兼容端点薄透传代理.
2
+
3
+ 端点 (https://ark.cn-beijing.volces.com/api/coding) 已完整支持
4
+ Anthropic Messages API 协议,仅做模型名映射和认证头替换。
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from ..config.schema import FailoverConfig
10
+ from ..config.vendors import DoubaoConfig
11
+ from ..routing.model_mapper import ModelMapper
12
+ from .native_anthropic import NativeAnthropicVendor
13
+
14
+
15
+ class DoubaoVendor(NativeAnthropicVendor):
16
+ """豆包 Doubao 原生 Anthropic 兼容端点供应商(薄透传)."""
17
+
18
+ _vendor_name = "doubao"
19
+ _display_name = "Doubao"
20
+
21
+ def __init__(
22
+ self,
23
+ config: DoubaoConfig,
24
+ model_mapper: ModelMapper,
25
+ failover_config: FailoverConfig | None = None,
26
+ ) -> None:
27
+ super().__init__(config, model_mapper, failover_config)
@@ -0,0 +1,27 @@
1
+ """Kimi 供应商 — 原生 Anthropic 兼容端点薄透传代理.
2
+
3
+ 端点 (https://api.kimi.com/coding/) 已完整支持
4
+ Anthropic Messages API 协议,仅做模型名映射和认证头替换。
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from ..config.schema import FailoverConfig
10
+ from ..config.vendors import KimiConfig
11
+ from ..routing.model_mapper import ModelMapper
12
+ from .native_anthropic import NativeAnthropicVendor
13
+
14
+
15
+ class KimiVendor(NativeAnthropicVendor):
16
+ """Kimi 原生 Anthropic 兼容端点供应商(薄透传)."""
17
+
18
+ _vendor_name = "kimi"
19
+ _display_name = "Kimi"
20
+
21
+ def __init__(
22
+ self,
23
+ config: KimiConfig,
24
+ model_mapper: ModelMapper,
25
+ failover_config: FailoverConfig | None = None,
26
+ ) -> None:
27
+ super().__init__(config, model_mapper, failover_config)