feat: enhance upstream endpoint handling with new passthrough header extraction and response management

- Introduced new types for endpoint preferences to support 'responses'.
- Added functions to extract safe passthrough headers, Claude-specific headers, and responses-specific headers.
- Implemented logic to ensure proper handling of stream accept headers.
- Updated endpoint resolution logic to prioritize 'responses' in certain contexts.
- Enhanced request building for 'messages' and 'responses' endpoints with improved body sanitization and header management.
- Added comprehensive documentation for new features and usage instructions.
This commit is contained in:
cita
2026-03-01 17:26:50 +08:00
parent af63df808d
commit 05a5ee9b9e
8 changed files with 2080 additions and 74 deletions
+8 -1
View File
@@ -64,9 +64,16 @@ Metapi 暴露标准 OpenAI / Claude 兼容接口,下游客户端只需配置
```bash
export ANTHROPIC_BASE_URL=https://your-domain.com
export ANTHROPIC_API_KEY=your-proxy-sk-token
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
# 可选:进一步关闭非必要模型调用
export DISABLE_NON_ESSENTIAL_MODEL_CALLS=1
```
或在配置文件中设置相应的环境变量。
或在配置文件中设置相应的环境变量(例如 `~/.claude/settings.json`)。
> 说明:上述变量由 Claude Code 客户端读取,属于客户端行为开关;
> `metapi` 服务端无法替代客户端“设置这些变量”,只能处理已经发来的请求。
### Roo Code / Kilo Code