675 Commits

Author SHA1 Message Date
huangzhenpc
9ad2c1f1bb fix: Filter out Accept-Encoding header in request passthrough to prevent compression
Fixed 'invalid character '\x1f' looking for beginning of value' error when sending images:
- Added accept-encoding to filtered headers in complete passthrough mode
- This prevents upstream from returning gzip compressed responses that new-api cannot parse
- Issue occurred when clients (like image uploads) had compression headers passed through directly

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-27 10:25:03 +08:00
huangzhenpc
4f44976214 fix: Remove compression headers to prevent JSON parsing errors
Fixed 'invalid character '\x1f' looking for beginning of value' error caused by gzip compression in setupKillcodeHeaders function:
- Removed 'Accept-Encoding: br, gzip, deflate' header that caused upstream to return compressed responses
- Removed browser-specific 'sec-fetch-mode: cors' header
- This prevents new-api from trying to parse compressed JSON as raw text

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-27 10:06:02 +08:00
huangzhenpc
38e17d621d feat(claude): 实现智能请求头管理系统
核心功能:
- 支持渠道级透传设置 (修复 killcode 客户端兼容性)
- 智能客户端检测 (Claude Code、killcode、其他客户端)
- 动态请求头策略 (透传 vs 伪装)

客户端处理策略:
- Claude Code (claude-cli/*): 完全透传原始请求头
- killcode (B2/JS + Stainless SDK): 完全透传原始请求头
- 其他客户端: 伪装成 killcode 格式绕过上游限制

技术改进:
- 防止显示 Go-http-client/2.0 User-Agent
- 保留重要认证头部 (anthropic-version, anthropic-beta)
- 兼容全局透传和渠道透传设置

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-26 16:24:51 +08:00
huangzhenpc
a8b11912df fix(claude): 修复 Claude 适配器不支持渠道透传的问题
- 将条件从只检查全局透传改为全局透传或渠道透传
- 与其他适配器保持一致的透传逻辑
- 修复 killcode 客户端在仅开启渠道透传时无法正常工作的问题

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-26 15:31:56 +08:00
huangzhenpc
60af0d1682 更新到官方v0.9.0-alpha.8真正最新版本并恢复自定义功能
 更新到官方真正的最新版本 v0.9.0-alpha.8
 恢复 Footer.jsx 自定义页脚 (听泉claude提供)
 恢复 Claude 穿透功能到 adaptor.go
 恢复 Docker 自定义配置 (端口3099)
 添加 service/channel_state_reporter.go

关键更新:
- 文件格式从 .js 更新为 .jsx (官方最新格式)
- Claude adaptor 保持穿透功能兼容性
- 全新的界面和功能改进

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 16:32:58 +08:00
CaIon
7fbf9c4851 feat: enhance image request handling and add async support 2025-08-24 21:52:56 +08:00
Nekohy
abcb353793 feats:add custom headers override 2025-08-24 01:02:23 +08:00
Calcium-Ion
e3a38d27f5 Merge pull request #1611 from nekohy/feats-zhipu_4v-anthropic
Feats:Standardize ClaudeHandler, add Zhipu_4v Anthropic native channel support
2025-08-23 13:48:18 +08:00
CaIon
e581422810 fix: update response body handling in OpenAI relay format 2025-08-22 17:33:20 +08:00
Calcium-Ion
ad151bb919 Merge pull request #1606 from funnycups/patch-1
fix: prompt calculation
2025-08-22 17:30:53 +08:00
creamlike1024
e02e1e8d4a fix: Guard against negative or zero n from ExtraBody to prevent uint underflow 2025-08-18 23:35:01 +08:00
Sh1n3zZ
974b93a8be feat: imagen for vertex channel 2025-08-18 21:49:55 +08:00
Nekohy
652d71d799 feats:Standardize ClaudeHandler, add zhipu_4v Anthropic native support 2025-08-18 13:14:48 +08:00
CaIon
0a053ee633 feat: 完善gemini格式转换 2025-08-17 19:08:06 +08:00
CaIon
c18414cbe4 refactor: extract FlushWriter function for improved stream flushing 2025-08-17 15:30:31 +08:00
funnycups
e3473e3c39 fix: prompt calculation
User will correctly get estimated prompt usage when upstream returns either zero or nothing.
2025-08-16 22:54:00 +08:00
CaIon
c834694992 fix: update token usage calculation 2025-08-16 19:11:15 +08:00
Calcium-Ion
5829bc69ca Merge pull request #1597 from wzxjohn/feature/add_openai_models
feat(relay): add OpenAI gpt-4.1 o3 o4 gpt-image-1 models
2025-08-16 12:27:20 +08:00
CaIon
0bb43aa464 refactor: update function signatures to include context and improve file handling #1599 2025-08-15 18:40:54 +08:00
wzxjohn
68b7badb80 feat(relay): add OpenAI gpt-4.1 o3 o4 gpt-image-1 models 2025-08-15 17:10:16 +08:00
CaIon
eeb421513b Merge remote-tracking branch 'origin/alpha' into alpha 2025-08-15 16:47:36 +08:00
Calcium-Ion
ef1e380bbc Merge pull request #1577 from nekohy/feats-better-adaptor-for-openrouter
Fix reasoning adaptor for openrouter
2025-08-15 16:19:24 +08:00
CaIon
d646a922ee refactor: set prompt tokens when not provided in usage 2025-08-15 15:55:01 +08:00
CaIon
726f1632b0 refactor: ensure graceful closure of response body in relay responses 2025-08-15 15:10:54 +08:00
CaIon
5fe1ce89ec refactor: improve request type validation and enhance sensitive information masking 2025-08-15 13:20:36 +08:00
CaIon
6748b006b7 refactor: centralize logging and update resource initialization
This commit refactors the logging mechanism across the application by replacing direct logger calls with a centralized logging approach using the `common` package. Key changes include:

- Replaced instances of `logger.SysLog` and `logger.FatalLog` with `common.SysLog` and `common.FatalLog` for consistent logging practices.
- Updated resource initialization error handling to utilize the new logging structure, enhancing maintainability and readability.
- Minor adjustments to improve code clarity and organization throughout various modules.

This change aims to streamline logging and improve the overall architecture of the codebase.
2025-08-14 21:10:04 +08:00
CaIon
e2037ad756 refactor: Introduce pre-consume quota and unify relay handlers
This commit introduces a major architectural refactoring to improve quota management, centralize logging, and streamline the relay handling logic.

Key changes:
- **Pre-consume Quota:** Implements a new mechanism to check and reserve user quota *before* making the request to the upstream provider. This ensures more accurate quota deduction and prevents users from exceeding their limits due to concurrent requests.

- **Unified Relay Handlers:** Refactors the relay logic to use generic handlers (e.g., `ChatHandler`, `ImageHandler`) instead of provider-specific implementations. This significantly reduces code duplication and simplifies adding new channels.

- **Centralized Logger:** A new dedicated `logger` package is introduced, and all system logging calls are migrated to use it, moving this responsibility out of the `common` package.

- **Code Reorganization:** DTOs are generalized (e.g., `dalle.go` -> `openai_image.go`) and utility code is moved to more appropriate packages (e.g., `common/http.go` -> `service/http.go`) for better code structure.
2025-08-14 20:05:06 +08:00
Nekohy
c1a545ac23 feats:the Openrouter Claude thinking 2025-08-12 22:39:32 +08:00
Nekohy
33925dd313 fix:Delete the excess ReasoningEffort from the Openrouter OpenAI thinking model. 2025-08-12 21:37:12 +08:00
CaIon
e77effaf8b fix(adaptor): optimize multipart form handling and resource management 2025-08-12 19:57:56 +08:00
Calcium-Ion
38c3349a6a Merge pull request #1569 from duyazhe/codex/cloudflare-responses
feat: add responses support for cloudflare
2025-08-12 14:13:14 +08:00
nekohy
14a9a99e2d fix: zhipu_v4 thinking 2025-08-11 21:37:10 +08:00
CaIon
e74c6f5de7 feat: Simplify response handling by returning raw response body directly 2025-08-11 20:07:24 +08:00
CaIon
d3170310ff feat: Refactor Gemini tools handling to support JSON raw message format 2025-08-11 19:48:04 +08:00
CaIon
53fa7255ec feat: Refactor model handling to use UpstreamModelName for request processing 2025-08-11 17:32:58 +08:00
CaIon
dddf772f19 feat: Update request URL handling for Claude relay format in adaptor #1557 2025-08-11 17:17:56 +08:00
CaIon
c7498b768c feat: Update Azure responses API version handling in adaptor 2025-08-11 16:34:07 +08:00
duyazhe
c87a741fc9 feat: add responses support for cloudflare 2025-08-11 15:29:16 +08:00
CaIon
7f462a084c feat: Add ChannelOtherSettings to manage additional channel configurations 2025-08-10 20:21:30 +08:00
Calcium-Ion
02fd80b703 Merge pull request #1537 from RedwindA/feat/support-native-gemini-embedding
feat: 支持原生Gemini Embedding格式
2025-08-10 10:26:46 +08:00
CaIon
ea8cac7c10 feat: add AWS invoke error handling and new error code 2025-08-09 19:26:41 +08:00
RedwindA
f242220132 feat: update dto for embeddings 2025-08-09 18:31:56 +08:00
RedwindA
03b670971b Merge branch 'alpha' into 'feat/support-native-gemini-embedding' 2025-08-09 18:05:11 +08:00
Calcium-Ion
3b61617cb1 Merge pull request #1500 from antecanis8/gemini_batchembedcontents
fix: Gemini embedding model only embeds the first text in a batch
2025-08-09 11:42:08 +08:00
RedwindA
7a31e481a6 fix typo; add ParamOverride for Gemini Embedding 2025-08-09 01:07:48 +08:00
RedwindA
b70d2655ed feat: support native Gemini Embedding 2025-08-09 00:27:33 +08:00
Yincmewy
15cb2f1a9e feats:replace GLM-4v authentication headers to support customize api key 2025-08-08 23:26:29 +08:00
CaIon
f6c7828160 feat: implement moonshot adaptor for request handling and response processing 2025-08-08 17:28:21 +08:00
CaIon
daa7a13505 feat: 完善格式抓换,修复gemini渠道和openai渠道在claude code中使用的问题 2025-08-08 16:45:37 +08:00
Calcium-Ion
f8e1b084cd Merge pull request #1524 from feitianbubu/pr/fix-last-resp
fix: ensure last message is sent successfully
2025-08-08 14:55:47 +08:00