Commit Graph

13 Commits

Author SHA1 Message Date
shaw
681cb8cd82 feat: 优化 Claude 模型缓存费用计算,支持 5 分钟和 1 小时两种缓存类型
- 在 pricingService 中硬编码 1 小时缓存价格(Opus: $30/MTok, Sonnet: $6/MTok, Haiku: $1.6/MTok)
- 更新 usage 捕获逻辑以分别记录 ephemeral_5m 和 ephemeral_1h 缓存 tokens
- 改进费用计算逻辑,正确计算两种缓存类型的费用
- 新增 recordUsageWithDetails 方法支持详细的缓存数据
- 保持向后兼容性,支持旧的数据格式
- 删除测试脚本 test-openai-refresh.js
- 修复 OpenAI token 刷新逻辑

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-16 22:31:20 +08:00
KevinLiao
87775c9fb1 fix: 修复Claude Console账号模型映射的的流式响应 2025-08-10 08:46:26 +08:00
千羽
8a74bf5afe refactor: standardize code formatting and linting configuration
- Replace .eslintrc.js with .eslintrc.cjs for better ES module compatibility
- Add .prettierrc configuration for consistent code formatting
- Update package.json with new lint and format scripts
- Add nodemon.json for development hot reloading configuration
- Standardize code formatting across all JavaScript and Vue files
- Update web admin SPA with improved linting rules and formatting
- Add prettier configuration to web admin SPA

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-07 18:19:31 +09:00
Wesley Liddick
6626d1d32a Merge pull request #208 from kevinconan/main
fix: 修改Claude Console 账号的UA默认行为,默认透传客户端UA而非固定的UA值
2025-08-07 12:38:36 +08:00
KevinLiao
ae7f4e2405 fix: 修改Claude Console 账号的UA默认行为,默认透传客户端UA而非固定的UA值 2025-08-07 12:33:32 +08:00
andersonby
e553734e42 chore: update user agent version to 1.0.69 in claudeConsoleAccountService and claudeConsoleRelayService 2025-08-07 00:53:14 +08:00
shinegod
3616245d49 feat: 全面增强 Claude Code 客户端支持与错误处理
## 🚀 新功能
- **智能认证系统**: 根据 API Key 格式自动选择认证方式
  - `sk-ant-*` 开头使用 `x-api-key` 认证(兼容 Anthropic 官方)
  - 其他格式使用 `Authorization: Bearer` 认证(兼容标准 REST API)
- **Claude Code 客户端完整支持**: 新增必需的 API 端点
  - `GET /v1/models` - 返回支持的模型列表
  - `GET /v1/me` - 用户信息端点
  - `GET /v1/organizations/:org_id/usage` - 使用统计查询

## 🔧 修复与优化
- **HTTP 协议合规性**: 修复响应头冲突导致的 502 错误
  - 避免同时发送 `Content-Length` 和 `Transfer-Encoding` 头部
  - 优化响应头过滤机制,确保代理兼容性
- **完全透传错误响应**: 保持上游 API 原始响应格式
  - 透传原始状态码、响应头和内容
  - 移除错误包装,直接转发原始 JSON 格式
  - 支持流式和非流式请求的错误透传
- **流式响应处理优化**:
  - 添加 `validateStatus: () => true` 配置
  - 改进错误处理逻辑,避免异常中断

## 📝 代码质量
- 修复 ESLint 代码规范警告
- 优化敏感头部过滤列表
- 改进调试日志输出

## 🎯 解决的问题
- Claude Code 客户端无法连接(502 Bad Gateway)
- 错误响应被包装而非透传原始格式
- sk-ant-* 格式 API Key 认证失败
- HTTP/2 代理环境下的响应头冲突

##  测试验证
- 本地测试完全透传上游错误响应
- Claude Code 客户端连接测试通过
- 智能认证机制验证成功
- HTTP 协议合规性确认
2025-08-06 14:27:57 +00:00
mouyong
80c6bed8c2 fix: 修复无法转发 opus 4.1 的问题 2025-08-06 15:26:49 +08:00
mouyong
e786ba8852 fix: 修复透传参数 2025-08-05 21:37:08 +08:00
KevinLiao
3c797a85e0 feat: Claude Console账号增强,升级模型支持列表为模型映射表! 2025-07-30 23:13:59 +08:00
shaw
a6ab6b7abe feat: 实现基于滑动窗口的实时RPM/TPM统计
- 添加系统级分钟统计,支持1-60分钟可配置时间窗口
- 新增 getRealtimeSystemMetrics 方法计算滑动窗口内的平均值
- 前端显示实时RPM/TPM,标注时间窗口和数据来源
- 修复 EditApiKeyModal 中模型限制和客户端限制复选框状态错误
- 优化性能:使用Pipeline批量操作替代Promise.all
- TPM包含所有token类型:input、output、cache_creation、cache_read
- 添加降级方案:实时数据不可用时返回历史平均值

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-30 15:37:57 +08:00
KevinLiao
89f9f48576 fix: 完成调度优先级逻辑的处理 2025-07-30 08:56:42 +08:00
KevinLiao
fddd5ee3e9 feat: 新增标准Claude Console API账号支持 2025-07-30 08:19:44 +08:00