RedwindA
f68858121c
fix(i18n): disable namespace separator to fix URL display in translations
...
i18next uses ':' as namespace separator by default, causing URLs like
'https://api.openai.com ' to be incorrectly parsed as namespace 'https'
with key '//api.openai.com', resulting in truncated display.
Setting nsSeparator to false fixes this issue since the project doesn't
use multiple namespaces.
2025-12-26 00:10:19 +08:00
Calcium-Ion
d3c854fbed
Merge pull request #2154 from feitianbubu/pr/fix-model-sync
...
fix: ensure overwrite works correctly when no missing models
2025-12-25 22:34:49 +08:00
Calcium-Ion
97b02685b1
Merge pull request #2475 from seefs001/feature/pyro
...
feat: pyroscope integrate
2025-12-25 17:54:39 +08:00
Seefs
da1b51ac31
Merge branch 'upstream-main' into feature/pyro
2025-12-25 17:08:02 +08:00
CaIon
f17b3810d6
feat(user): simplify user response structure in JSON output
v0.10.3
2025-12-25 15:39:58 +08:00
Calcium-Ion
8206084a77
Merge pull request #2524 from seefs001/fix/revert-model-ratio
...
fix: revert model ratio
2025-12-25 15:38:36 +08:00
Seefs
559da6362a
fix: revert model ratio
2025-12-25 15:37:54 +08:00
Calcium-Ion
0b1a562df9
Merge pull request #2477 from 1420970597/fix/anthropic-cache-billing
...
fix: 修复 Anthropic 渠道缓存计费错误
2025-12-24 16:59:23 +08:00
Seefs
a0c3d37d66
Merge pull request #2493 from shikaiwei1/patch-1
2025-12-24 16:52:24 +08:00
Seefs
347f2326f3
Merge pull request #2511 from JerryKwan/issue2499
2025-12-24 16:51:51 +08:00
Jerry
31a79620ba
Resolving event mismatch in OpenAI2Claude
...
add stricter validation for content_block_start corresponding to
tool call
and fix the crash issue when Claude Code is processing tool call
2025-12-24 14:52:39 +08:00
Calcium-Ion
12555a37d3
Merge pull request #2510 from feitianbubu/pr/0e7050dc89c1b761069f5e528d8ecf786e7008ae
...
修复claudeResponse流式请求空指针Panic
2025-12-24 14:15:51 +08:00
feitianbubu
3652dfdbd5
fix: check claudeResponse delta StopReason nil point
2025-12-24 11:54:23 +08:00
CaIon
42109c5840
feat(token): enhance error handling in ValidateUserToken for better clarity
2025-12-22 18:01:38 +08:00
John Chen
dbaba87c39
为Moonshot添加缓存tokens读取逻辑
...
为Moonshot添加缓存tokens读取逻辑。其与智普V4的逻辑相同,所以共用逻辑
2025-12-22 17:05:16 +08:00
Calcium-Ion
afd9c29ace
Merge pull request #2486 from QuantumNous/docs/readme-update-doc-links-new-routing
...
🔗 docs(readme): update documentation links to new site routing
2025-12-21 21:28:35 +08:00
t0ng7u
470e0304d8
🔗 docs(readme): revert missing docs links to legacy site
...
Keep new-site links (/{lang}/docs/...) where matching pages exist in the current docs repo
Revert links that have no equivalent in the new docs to the legacy paths on doc.newapi.pro:
Google Gemini Chat
Midjourney-Proxy image docs
Suno music docs
Apply the same rule consistently across all README translations (zh/en/ja/fr)
2025-12-21 21:18:59 +08:00
t0ng7u
d6e97ab184
🔗 docs(readme): update documentation links to new site routing
...
- Replace legacy `docs.newapi.pro` paths with the new `/{lang}/docs/...` structure across all README translations
- Point key sections (installation, env vars, API, support, features) to their new locations
- Ensure language-specific links use the correct locale prefix (zh/en/ja) and keep FR aligned with English routes
2025-12-21 21:00:33 +08:00
Calcium-Ion
d8aa327f05
Merge pull request #2483 from seefs001/fix/vertex-function-response-id
...
fix: 模型设置增加针对Vertex渠道过滤content[].part[].functionResponse.id的选项,默认启用
v0.10.2
2025-12-21 17:24:07 +08:00
Seefs
28f7a4feef
fix: 在Vertex Adapter过滤content[].part[].functionResponse.id
2025-12-21 17:22:04 +08:00
Seefs
5a64ae2a29
fix: 模型设置增加针对Vertex渠道过滤content[].part[].functionResponse.id的选项,默认启用
2025-12-21 17:09:49 +08:00
长安
0a2f12c04e
fix: 修复 Anthropic 渠道缓存计费错误
...
## 问题描述
当使用 Anthropic 渠道通过 `/v1/chat/completions` 端点调用且启用缓存功能时,
计费逻辑错误地减去了缓存 tokens,导致严重的收入损失(94.5%)。
## 根本原因
不同 API 的 `prompt_tokens` 定义不同:
- **Anthropic API**: `input_tokens` 字段已经是纯输入 tokens(不包含缓存)
- **OpenAI API**: `prompt_tokens` 字段包含所有 tokens(包含缓存)
- **OpenRouter API**: `prompt_tokens` 字段包含所有 tokens(包含缓存)
当前 `postConsumeQuota` 函数对所有渠道都减去缓存 tokens,这对 Anthropic
渠道是错误的,因为其 `input_tokens` 已经不包含缓存。
## 修复方案
在 `relay/compatible_handler.go` 的 `postConsumeQuota` 函数中,添加渠道类型判断:
```go
if relayInfo.ChannelType != constant.ChannelTypeAnthropic {
baseTokens = baseTokens.Sub(dCacheTokens)
}
```
只对非 Anthropic 渠道减去缓存 tokens。
## 影响分析
### ✅ 不受影响的场景
1. **无缓存调用**(所有渠道)
- cache_tokens = 0
- 减去 0 = 不减去
- 结果:完全一致
2. **OpenAI/OpenRouter 渠道 + 缓存**
- 继续减去缓存(因为 ChannelType != Anthropic)
- 结果:完全一致
3. **Anthropic 渠道 + /v1/messages 端点**
- 使用 PostClaudeConsumeQuota(不修改)
- 结果:完全不受影响
### ✅ 修复的场景
4. **Anthropic 渠道 + /v1/chat/completions + 缓存**
- 修复前:错误地减去缓存,导致 94.5% 收入损失
- 修复后:不减去缓存,计费正确
## 验证数据
以实际记录 143509 为例:
| 项目 | 修复前 | 修复后 | 差异 |
|------|--------|--------|------|
| Quota | 10,489 | 191,330 | +180,841 |
| 费用 | ¥0.020978 | ¥0.382660 | +¥0.361682 |
| 收入恢复 | - | - | **+1724.1%** |
## 测试建议
1. 测试 Anthropic 渠道 + 缓存场景
2. 测试 OpenAI 渠道 + 缓存场景(确保不受影响)
3. 测试无缓存场景(确保不受影响)
## 相关 Issue
修复 Anthropic 渠道使用 prompt caching 时的计费错误。
2025-12-20 14:17:12 +08:00
CaIon
cc3ba39e72
feat(gin): improve request body handling and error reporting
v0.10.1
2025-12-20 13:34:10 +08:00
CaIon
4ee595c448
feat(init): increase MaxRequestBodyMB to enhance request handling
2025-12-20 13:27:55 +08:00
CaIon
d9634ad2d3
feat(channel): add error handling for SaveWithoutKey when channel ID is 0
2025-12-20 13:26:40 +08:00
Seefs
a343ce84ee
Merge pull request #2476 from TinsFox/chore/code-inspector-plugin
2025-12-20 11:04:40 +08:00
Seefs
531dfb2555
docs: document pyroscope env var
2025-12-19 23:16:56 +08:00
TinsFox
e6ec551fbf
chore: add code-inspector-plugin integration
2025-12-19 23:04:53 +08:00
Seefs
5ef7247eac
docs: document pyroscope env var
2025-12-19 23:03:04 +08:00
Seefs
1168ddf9f9
fix: systemname
2025-12-19 22:27:35 +08:00
Seefs
a98aad2501
Merge pull request #2474 from TinsFox/main
2025-12-19 21:39:56 +08:00
TinsFox
97132de2ca
style: add card spacing
2025-12-19 21:00:31 +08:00
Seefs
b35ae9f693
Merge pull request #2452 from QuantumNous/fix/oom-request-body-limit
2025-12-16 18:21:59 +08:00
t0ng7u
8cb56fc319
🧹 fix: harden request-body size handling and error unwrapping
...
Tighten oversized request handling across relay paths and make error matching reliable.
- Align `MAX_REQUEST_BODY_MB` fallback to `32` in request body reader and decompression middleware
- Stop ignoring `GetRequestBody` errors in relay retry paths; return consistent **413** on oversized bodies (400 for other read errors)
- Add `Unwrap()` to `types.NewAPIError` so `errors.Is/As` can match wrapped underlying errors
- `go test ./...` passes
2025-12-16 18:10:00 +08:00
t0ng7u
8e3f9b1faa
🛡️ fix: prevent OOM on large/decompressed requests; skip heavy prompt meta when token count is disabled
...
Clamp request body size (including post-decompression) to avoid memory exhaustion caused by huge payloads/zip bombs, especially with large-context Claude requests. Add a configurable `MAX_REQUEST_BODY_MB` (default `32`) and document it.
- Enforce max request body size after gzip/br decompression via `http.MaxBytesReader`
- Add a secondary size guard in `common.GetRequestBody` and cache-safe handling
- Return **413 Request Entity Too Large** on oversized bodies in relay entry
- Avoid building large `TokenCountMeta.CombineText` when both token counting and sensitive check are disabled (use lightweight meta for pricing)
- Update READMEs (CN/EN/FR/JA) with `MAX_REQUEST_BODY_MB`
- Fix a handful of vet/formatting issues encountered during the change
- `go test ./...` passes
2025-12-16 17:00:19 +08:00
Calcium-Ion
11593bd3da
Merge pull request #2445 from QuantumNous/feat/token-ip-whitelist-cidr
...
feat(auth): enhance IP restriction handling with CIDR support
2025-12-15 20:14:09 +08:00
CaIon
e16e7d6fb9
feat(auth): refactor IP restriction handling to use clearer variable naming
2025-12-15 20:13:09 +08:00
CaIon
39593052b6
feat(auth): enhance IP restriction handling with CIDR support
2025-12-15 17:24:09 +08:00
CaIon
4ea8cbd207
Revert "feat(audio): replace SysLog with logger for improved logging in GetAudioDuration"
...
This reverts commit e293be0138 .
v0.10.1-alpha.8
2025-12-14 00:04:40 +08:00
CaIon
e293be0138
feat(audio): replace SysLog with logger for improved logging in GetAudioDuration
2025-12-13 23:59:58 +08:00
CaIon
9c2483ef48
fix(audio): improve WAV duration calculation with enhanced PCM size handling
2025-12-13 23:57:32 +08:00
CaIon
689c43143b
feat(model_ratio): add default ratios for gpt-4o-mini-tts
2025-12-13 19:14:27 +08:00
CaIon
a2da6a9e90
refactor(channel_select): improve retry logic with reset functionality
2025-12-13 18:09:10 +08:00
Calcium-Ion
7a307e2e99
Merge pull request #2434 from QuantumNous/feat/gpt-4o-mini-tts
...
feat: support gpt tts series model quota calculate
v0.10.1-alpha.6
2025-12-13 17:55:16 +08:00
CaIon
7cae4a640b
fix(audio): correct TotalTokens calculation for accurate usage reporting
2025-12-13 17:49:57 +08:00
CaIon
e36e2e1b69
feat(audio): enhance audio request handling with token type detection and streaming support
2025-12-13 17:24:23 +08:00
CaIon
b602843ce1
feat(token): add CrossGroupRetry field to token insertion
2025-12-13 16:45:42 +08:00
CaIon
21fca238bf
refactor(error): replace dto.OpenAIError with types.OpenAIError for consistency
2025-12-13 16:43:57 +08:00
CaIon
c51936e068
refactor(channel_select): enhance retry logic and context key usage for channel selection
2025-12-13 16:43:38 +08:00
Seefs
fcafadc6bb
feat: pyroscope integrate
2025-12-13 13:49:38 +08:00