Merge pull request #80 from shenhao-stu/main

docs: update mykey_template.py
This commit is contained in:
LJQ
2026-04-16 19:52:02 +08:00
committed by GitHub

View File

@@ -1,23 +1,52 @@
# ══════════════════════════════════════════════════════════════════════════════
# GenericAgent — mykey.py 配置模板(复制为 mykey.py 后填入真实凭证)
# ══════════════════════════════════════════════════════════════════════════════
# 文件中的每个"变量"即一条 session 配置。agentmain.py 只扫描变量名同时包含
# 'api' / 'config' / 'cookie' 的条目,根据变量名里的关键字决定实例化哪个
# Session 类型:
#
# 关键字组合 → Session 类
# ────────────────────────────────────────────────────────────
# 含 'native' 且 'claude' → NativeClaudeSession (Claude 原生协议 + 原生工具)
# 含 'native' 且 'oai' → NativeOAISession (OpenAI 协议 + 原生工具)
# 含 'claude'(不含 native → ClaudeSession (Claude 原生协议 + 文本协议工具)
# 含 'oai'(不含 native → LLMSession (OpenAI 协议 + 文本协议工具)
# 含 'sider' → SiderLLMSession
# 含 'mixin' → MixinSession (多 session 故障转移)
# ┌─────────────────────────────────────────────────────────────────────────┐
# │ 快速上手:只需 3 步 │
# 1. 把本文件复制为 mykey.py │
# 2. 在下面的"推荐最优配置"区域填入你的 apikey │
# 3. 运行 python agentmain.py / python launch.pyw │
# └─────────────────────────────────────────────────────────────────────────┘
#
# ────────── Session 类型速查 ──────────
#
# agentmain.py 只扫描变量名同时包含 'api' / 'config' / 'cookie' 的条目,
# 根据变量名里的关键字决定实例化哪个 Session 类型:
#
# 变量名关键字 → Session 类 → 工具协议
# ─────────────────────────────────────────────────────────────────────────
# 含 'native' 且 'claude' → NativeClaudeSession → API 原生 tool 字段
# 含 'native' 且 'oai' → NativeOAISession → API 原生 tool 字段
# 含 'claude'(不含 native → ClaudeSession → 文本协议工具 (deprecated)
# 含 'oai'(不含 native → LLMSession → 文本协议工具 (deprecated)
# 含 'mixin' → MixinSession → 多 session 故障转移
# NativeClaudeSession 与
# NativeOAISession 可混用
#
# 优先级自上而下native_claude_xxx 会走 NativeClaudeSession如果变量名只写
# oai_claude_xxx 则依然会被 'claude' 抢先匹配,去走 ClaudeSession所以命名要
# 注意含义。
#
# ────────── Native vs 非 Native 的区别 ──────────
#
# 「Native」 = 工具调用走 API 文档里的 tool 字段function calling
# 这是 Claude Code / Codex 的原生方式——训到 overfit 的模型只认 API tool 字段,
# 其他格式的工具描述都会被忽略。要模拟 CC/Codex 的行为,必须用 Native。
#
# 「非 Native」 = 工具描述放在 text 字段里(文本协议),兼容性更强,
# 但对于被 API tool 字段训 overfit 的模型(如 Claude Opus/Sonnet效果可能打折。
#
# → 新手推荐:优先用 native_claude_config / native_oai_config
#
# ────────── Prompt Cache 说明 ──────────
#
# NativeClaudeSession 恒开 prompt-caching-scope beta缓存默认拉满无需配置。
# LLMSession / NativeOAISession 在 model 名含 'claude'/'anthropic' 时自动在
# 最后两条 user 打 cache_control: ephemeral默认也是开启的。
# prompt_cache 字段默认 True仅在上游 relay 不认 cache_control 字段会直接报错
# 时才需设 False。因此模板中不再显式写 prompt_cache了解即可。
#
# ══════════════════════════════════════════════════════════════════════════════
# apibase 自动拼接规则:
# 'http://host:2001' → 补 /v1/chat/completions
@@ -52,7 +81,7 @@
# context_win 默认 24000NativeClaudeSession 默认 28000。仅作为历史裁
# 剪阈值,不是硬上下文限制。
# max_retries 默认 1。_openai_stream 遇到 429/408/5xx 的自动重试次数。
# timeout 连接超时秒数,默认 5。
# connect_timeout 连接超时秒数,默认 5。
# read_timeout 流式读取超时秒数,默认 30。
# ─── 推理 / 思考 ─────────────────────────────────────────────────────────────
# reasoning_effort OpenAI o 系列或 Responses API 的思考预算等级。Claude 侧
@@ -73,51 +102,173 @@
# 以改成 False 先保命。
# api_mode 'chat_completions'(默认)或 'responses'。仅对 LLMSession /
# NativeOAISession 生效。
# ─── 缓存 ──────────────────────────────────────────────────────────────────
# prompt_cache 默认 True。NativeClaudeSession 恒开启双滚动 cache_control
# LLMSession/NativeOAISession 走 OAI 中继时,若 model 名含
# 'claude' 或 'anthropic' 会自动在最后两条 user 打
# cache_control: ephemeral。设 False 只有在上游 relay 不认
# cache_control 字段会直接报错时才用。
# ─── NativeClaudeSession 专属 ───────────────────────────────────────────────
# fake_cc_system_prompt
# 默认 False。关键字段**所有反代/镜像 Claude Code 协议的渠道
# 都必须置 True**anyrouter、claude-relay-service 等)。
# 都必须置 True**CC switch、anyrouter、claude-relay-service
# 等)。真 Anthropic 端点sk-ant-)不需要开。
# ══════════════════════════════════════════════════════════════════════════════
# ══════════════════════════════════════════════════════════════════════════════
# 示例 1 — OpenRouter (OAI 协议 → Claude / GPT / Gemini 等,含缓存优化)
# ──────────────────────────────────────────────────────────────────────────────
# OpenRouter 是最通用的多模型 OAI 中继https://openrouter.ai/api/v1。
# model 名用 provider/model 格式(如 anthropic/claude-opus-4-6
# ═══════════════════════════════════════════════════════════════════════════
# ║ ★ 推荐最优配置(新手从这里开始)★ ║
# ╚═══════════════════════════════════════════════════════════════════════════╝
#
# 推荐使用 mixin 故障转移 + 多个 native session 的方式
# mixin 会按 llm_nos 列表顺序尝试,第一个失败自动切下一个,非常省心。
# 填好下面的 apikey/apibase 后即可使用。
oai_config_openrouter = {
'name': 'openrouter-claude', # /llms 显示名 & mixin 引用名;省略则取 model
'apikey': 'sk-or-<your-openrouter-key>', # OpenRouter key 形如 sk-or-xxxBearer 鉴权
'apibase': 'https://openrouter.ai/api/v1', # 补齐到 /v1/chat/completions
'model': 'anthropic/claude-opus-4-6', # provider/model 格式;名含 'claude' 会自动打 ephemeral
'api_mode': 'chat_completions', # 'chat_completions'(默认)|'responses'
'prompt_cache': True, # bool 默认 True关掉会禁用 cache_control 标记
'temperature': 1, # float 默认 1.0;非负
'max_tokens': 16384, # int 默认 8192回复最大 token 数
'max_retries': 3, # int 默认 1429/408/5xx 自动重试次数
'connect_timeout': 10, # int 秒 默认 5最小 1TCP 连接超时
'read_timeout': 120, # int 秒 默认 30最小 5流式读取单次超时
# 'context_win': 60000, # int 默认 24000历史裁剪 token 阈值,非硬上下文
# 'proxy': 'http://127.0.0.1:2082', # 可选单 session 代理;不填则不走代理
# ── Mixin 故障转移(最推荐的方式)──────────────────────────────────────────
# llm_nos 里的字符串必须和被引用 session 的 'name' 字段匹配(也可以写整数索
# 引)。约束:引用的 session 必须全是 Native 系列NativeClaudeSession
# NativeOAISession 可以混用)或者全不是 Native不能 Native 与非 Native 混。
mixin_config = {
'llm_nos': ['cc-relay-1', 'cc-relay-2', 'gpt-native'], # 按优先级排列Claude 与 GPT 混用
'max_retries': 10, # int整个 rotation 的总重试次数上限
'base_delay': 0.5, # float 秒指数退避起始延迟retry n 时延迟≈base_delay * 2^n
# 'spring_back': 300, # int 秒;切到备用节点后多久再尝试回到第一个节点
}
# ══════════════════════════════════════════════════════════════════════════════
# 示例 2 — 通用 OAI 兼容代理 (chat/completions 模式)
# ──────────────────────────────────────────────────────────────────────────────
# 任何支持 /v1/chat/completions 的中转站ohmyapi、one-api、newapi 等)都用
# 这种方式。变量名含 'oai' 即可。支持 GPT / Claude / Gemini / Grok 等。
oai_config = {
'name': 'my-oai-proxy', # /llms 显示名 & mixin 引用名
'apikey': 'sk-<your-proxy-key>', # Bearer 鉴权
'apibase': 'http://<your-proxy-host>:2001', # 自动补 /v1/chat/completions
'model': 'gpt-5.4', # 或 claude-opus-4-6、gemini-3-flash 等
# 1. NativeClaudeSession — Anthropic 原生协议 + 原生工具(推荐首选)
# ══════════════════════════════════════════════════════════════════════════════
#
# 大部分用户使用的是 CC switch 适配的 Claude 透传渠道(非官方直连),这类渠道
# 把 Claude Code 的请求透传到上游,需要 fake_cc_system_prompt=True。
# 这是目前社区最常见的接入方式。
# ── 1a. CC switch 适配渠道(最常用)────────────────────────────────────────
# 这类渠道把 Claude Code 协议透传到上游apikey 格式各异sk-user-*, sk-*, cr_*
# 等),统一走 Bearer 鉴权。必须设置 fake_cc_system_prompt=True。
native_claude_config0 = {
'name': 'cc-relay-1', # /llms 显示名 & mixin 引用名
'apikey': 'sk-user-<your-relay-key>', # 非 sk-ant- 前缀 → Bearer 鉴权
'apibase': 'https://<your-cc-switch-host>/claude/office', # CC switch 端点
'model': 'claude-opus-4-6', # 或 claude-sonnet-4-6
'fake_cc_system_prompt': True, # CC 透传渠道必须置 True
}
native_claude_config1 = {
'name': 'cc-relay-2', # /llms 显示名 & mixin 引用名
'apikey': 'sk-<your-second-relay-key>',
'apibase': 'https://<your-second-host>',
'model': 'claude-opus-4-6[1m]', # [1m] 触发 1m 上下文 beta
'fake_cc_system_prompt': True,
'max_retries': 3,
'read_timeout': 300, # 1m 上下文响应可能较慢
# 'stream': False, # 某些渠道不支持 SSE 流式时改 False
}
# ── 1b. Anthropic 官方直连 ──────────────────────────────────────────────────
# 官方端点apikey 以 sk-ant- 开头 → 自动切到 x-api-key 鉴权。
# 真 Anthropic 端点不需要 fake_cc_system_prompt。
# native_claude_config_anthropic = {
# 'name': 'anthropic-direct', # /llms 显示名 & mixin 引用名
# 'apikey': 'sk-ant-<your-anthropic-key>', # sk-ant- 前缀 → 自动走 x-api-key 头
# 'apibase': 'https://api.anthropic.com', # NativeClaudeSession 自动附加 ?beta=true
# 'model': 'claude-opus-4-6[1m]', # [1m] 触发 1m 上下文 beta
# # ── 思考控制thinking_type 与 reasoning_effort 独立,可同时写)──
# 'thinking_type': 'adaptive', # 合法值: 'adaptive' / 'enabled' / 'disabled'
# # adaptive = Claude Code 默认,模型自决预算
# # enabled = 必须配 thinking_budget_tokens
# # disabled = 发送 {"type":"disabled"}
# # 'thinking_type': 'enabled',
# # 'thinking_budget_tokens': 32768, # int仅 thinking_type='enabled' 生效
# # 参考: low≈4096 / medium≈10240 / high≈32768
# # ── 推理等级Claude 侧写进 payload.output_config.effort──
# # 合法值: 'none' / 'minimal' / 'low' / 'medium' / 'high' / 'xhigh'
# # 映射: low/medium/high 原值传递xhigh → 'max'
# # none/minimal 被 llmcore 打 WARN 丢弃Claude 不支持这两档)
# # 运行时可覆盖: REPL 输入 /session.reasoning_effort=high 当场生效
# # 'reasoning_effort': 'high',
# 'temperature': 1, # float 默认 1.0
# 'max_tokens': 32768, # int 默认 8192Claude 回复最大 token 数
# # 'context_win': 800000, # int 默认 28000NativeClaudeSession历史裁剪阈值
# # 'stream': True, # bool 默认 TrueFalse → 一次性 JSONCDN 截断 SSE 时用)
# # 'max_retries': 3, # int 默认 1
# # 'connect_timeout': 10, # int 秒 默认 5最小 1
# # 'read_timeout': 180, # int 秒 默认 30最小 5
# # 'fake_cc_system_prompt': False, # bool 默认 False真 Anthropic 端点不需开
# }
# ── 1c. CRS 反代 Claude Max ─────────────────────────────────────────────────
# CRS 需要 fake_cc_system_prompt=True
# native_claude_config_crs = {
# 'name': 'crs-claude-max', # /llms 显示名
# 'apikey': 'cr_<your-crs-key>', # cr_ 开头 → Bearer 鉴权64 位 hex
# 'apibase': 'https://<your-crs-host>/api',# CRS 的 Anthropic 兼容路径
# 'model': 'claude-opus-4-6[1m]', # [1m] 触发 1m beta
# 'fake_cc_system_prompt': True, # bool 必填 TrueCRS 也校验 CC 系统串
# 'thinking_type': 'adaptive', # 'adaptive'/'enabled'/'disabled'
# # 'reasoning_effort': 'high', # 可选;写进 output_config.effort
# 'max_tokens': 32768, # intCRS 允许大 max_tokens
# 'max_retries': 3, # int
# 'read_timeout': 180, # int 秒
# }
# ── 1d. CRS Gemini Ultra (Antigravity 通道) ─────────────────────────────────
# CRS 把 Google Antigravity (Gemini Ultra) 包装成 Anthropic 风格接口。
# URL 路径带 /antigravity/api
# - 'claude-opus-4-6-thinking' (CRS 原始名)
# - 'claude-opus-4-6[1m]' (触发 1m betaCRS 会忽略多余的 beta)
# - 'claude-opus-4-6' (最简)
# ⚠ 此通道不支持 SSE 流式,必须 stream=False。
# native_claude_config_crs_gemini = {
# 'name': 'crs-gemini-ultra', # /llms 显示名
# 'apikey': 'cr_<your-crs-gemini-key>', # cr_ 前缀 → Bearer
# 'apibase': 'https://<your-crs-gemini-host>/antigravity/api',
# 'model': 'claude-opus-4-6-thinking', # 或 'claude-opus-4-6[1m]' 或 'claude-opus-4-6'
# 'stream': False, # Antigravity 不支持 SSE 流式stream=True 会返回伪错误
# 'max_tokens': 32768, # int
# 'max_retries': 3, # int
# 'read_timeout': 180, # int 秒
# }
# ── 1e. 智谱 GLM-5.1 (Anthropic 兼容协议) ──────────────────────────────────
# 智谱提供了 Anthropic 兼容接口 /api/anthropic走 NativeClaudeSession。
# 变量名含 'native' + 'claude' 即可。apikey 是智谱格式 (xxx.yyy)。
# native_claude_glm_config = {
# 'name': 'glm-5.1', # /llms 显示名
# 'apikey': '<your-zhipu-apikey>', # 形如 f0f1b798xxxx.F8SSbzxxxx非 sk-ant- → Bearer
# 'apibase': 'https://open.bigmodel.cn/api/anthropic', # 智谱 Anthropic 兼容端点
# 'model': 'glm-5.1', # 智谱 model id无 [1m] 支持
# 'max_retries': 3, # int
# 'connect_timeout': 10, # int 秒
# 'read_timeout': 180, # int 秒
# # 'fake_cc_system_prompt': False, # 智谱不做 CC 指纹校验,保持默认 False
# }
# ── 1f. MiniMax Anthropic 路径(推荐——无额外 <think> 标签)────────────────
# MiniMax 同时提供 OAI 和 Anthropic 兼容接口,同一个 key 两个端点都能用:
# - /v1 → chat/completions (LLMSession)
# - /anthropic → Anthropic Messages (NativeClaudeSession)
# Anthropic 路径更简洁OAI 路径会返回 <think> 标签M2.7 自带思考)。
# 温度自动修正为 (0, 1],支持 M2.7 / M2.5 全系列204K 上下文。
# native_claude_config_minimax = {
# 'name': 'minimax-anthropic', # /llms 显示名
# 'apikey': 'sk-<your-minimax-key>', # 与 OAI 路径同一个 key
# 'apibase': 'https://api.minimaxi.com/anthropic', # Anthropic Messages 兼容端点
# 'model': 'MiniMax-M2.7',
# 'max_retries': 3, # int
# # 'fake_cc_system_prompt': False, # MiniMax 不做 CC 指纹校验
# }
# ══════════════════════════════════════════════════════════════════════════════
# 2. NativeOAISession — OpenAI 协议 + 原生工具
# ══════════════════════════════════════════════════════════════════════════════
# 变量名含 'native' 且 'oai'。走 OpenAI chat/completions 或 responses 端点,
# 但工具调用使用 API 原生 function calling 字段(与 Claude Code/Codex 一致)。
# 适合 GPT/o 系列、Gemini 或任何 OAI 兼容且支持原生 tool 字段的模型。
# 和 NativeClaudeSession 共用大部分逻辑(继承关系),只是请求走 OAI 协议。
native_oai_config = {
'name': 'gpt-native', # /llms 显示名 & mixin 引用名
'apikey': 'sk-<your-openai-key>', # Bearer 鉴权
'apibase': 'https://api.openai.com/v1', # 补齐到 /v1/chat/completions
'model': 'gpt-5.4', # gpt-5/o 系列
'api_mode': 'chat_completions', # 'chat_completions'(默认)|'responses'
# 'reasoning_effort': 'high', # none|minimal|low|medium|high|xhigh
# chat_completions → payload.reasoning_effort
@@ -127,25 +278,14 @@ oai_config = {
'read_timeout': 120, # int 秒 默认 30最小 5
# 'temperature': 1.0, # float 默认 1.0
# 'max_tokens': 8192, # int 默认 8192
# 'prompt_cache': True, # bool 默认 True仅 model 名含 claude/anthropic 时生效
# 'proxy': 'http://127.0.0.1:2082', # 可选单 session HTTP 代理
# 'context_win': 16000, # int 默认 24000历史裁剪阈值
}
# 多配几个也行,变量名含 'oai' 即可
# oai_config2 = {
# 'apikey': 'sk-...',
# 'apibase': 'http://your-proxy:2001',
# 'model': 'claude-opus-4-6',
# }
# ══════════════════════════════════════════════════════════════════════════════
# 示例 3 — OpenAI Responses API (gpt/o 系列reasoning_effort 支持)
# ──────────────────────────────────────────────────────────────────────────────
# ── 也可以走 Responses API ──────────────────────────────────────────────────
# 对接 OpenAI /v1/responses 端点。reasoning_effort 会以 reasoning.effort
# 字段写进 payload运行时也可用 /session.reasoning_effort=high 现场调。
# oai_config_responses = {
# native_oai_config_responses = {
# 'name': 'gpt-responses', # /llms 显示名
# 'apikey': 'sk-<your-openai-key>', # Bearer 鉴权
# 'apibase': 'https://api.openai.com/v1', # 补齐到 /v1/responses因为 api_mode=responses
@@ -159,157 +299,53 @@ oai_config = {
# ══════════════════════════════════════════════════════════════════════════════
# 示例 4 — Anthropic 原生 (api.anthropic.com)
# ──────────────────────────────────────────────────────────────────────────────
# 官方端点apikey 以 sk-ant- 开头 → 自动切到 x-api-key 鉴权
native_claude_config_anthropic = {
'name': 'anthropic-direct', # /llms 显示名 & mixin 引用名
'apikey': 'sk-ant-<your-anthropic-key>', # sk-ant- 前缀 → 自动走 x-api-key 头
'apibase': 'https://api.anthropic.com', # Messages 端点NativeClaudeSession 自动附加 ?beta=true
'model': 'claude-opus-4-6[1m]', # [1m] 触发 context-1m-2025-08-07 beta上游前自动剥掉
# ── 思考控制thinking_type 与 reasoning_effort 独立,可同时写)──
'thinking_type': 'adaptive', # 合法值: 'adaptive' / 'enabled' / 'disabled'
# adaptive = Claude Code 默认,模型自决预算
# enabled = 必须配 thinking_budget_tokens
# disabled = 发送 {"type":"disabled"}
# 'thinking_type': 'enabled',
# 'thinking_budget_tokens': 32768, # int仅 thinking_type='enabled' 生效
# 参考: low≈4096 / medium≈10240 / high≈32768
# ── 推理等级Claude 侧写进 payload.output_config.effort──
# 合法值: 'none' / 'minimal' / 'low' / 'medium' / 'high' / 'xhigh'
# 映射: low/medium/high 原值传递xhigh → 'max'
# none/minimal 被 llmcore 打 WARN 丢弃Claude 不支持这两档)
# 运行时可覆盖: REPL 输入 /session.reasoning_effort=high 当场生效
# 'reasoning_effort': 'high',
'temperature': 1, # float 默认 1.0
'max_tokens': 32768, # int 默认 8192Claude 回复最大 token 数
# 'context_win': 800000, # int 默认 28000NativeClaudeSession历史裁剪阈值
# 'prompt_cache': True, # bool 默认 TrueNativeClaudeSession 恒开双滚动 cache_control
# 'stream': True, # bool 默认 TrueFalse → 一次性 JSONCDN 截断 SSE 时用)
# 3. LLMSession / ClaudeSession — 非 Native 文本协议工具deprecated
# ══════════════════════════════════════════════════════════════════════════════
# ⚠ 后续版本可能移除非 Native session。新用户请直接使用上面的 Native 配置
# 非 Native 把工具描述放在 text 字段里,兼容性广但对 overfit 模型效果打折。
# 变量名含 'oai'(不含 native→ LLMSession含 'claude'(不含 native→ ClaudeSession。
#
# oai_config = {
# 'name': 'my-oai-proxy', # /llms 显示名 & mixin 引用名
# 'apikey': 'sk-<your-proxy-key>', # Bearer 鉴权
# 'apibase': 'http://<your-proxy-host>:2001', # 自动补 /v1/chat/completions
# 'model': 'gpt-5.4', # 或 claude-opus-4-6、gemini-3-flash 等
# 'api_mode': 'chat_completions', # 'chat_completions'(默认)|'responses'
# # 'reasoning_effort': 'high', # none|minimal|low|medium|high|xhigh
# 'max_retries': 3, # int 默认 1
# 'connect_timeout': 10, # int 秒 默认 5最小 1
# 'read_timeout': 180, # int 秒 默认 30最小 5
# 'fake_cc_system_prompt': False, # bool 默认 False真 Anthropic 端点不需开
}
# 'read_timeout': 120, # int 秒 默认 30最小 5
# # 'temperature': 1.0, # float 默认 1.0
# # 'max_tokens': 8192, # int 默认 8192
# # 'proxy': 'http://127.0.0.1:2082', # 可选单 session HTTP 代理
# # 'context_win': 16000, # int 默认 24000历史裁剪阈值
# }
#
# # 多配几个也行,变量名含 'oai' 即可
# # oai_config2 = {
# # 'apikey': 'sk-...',
# # 'apibase': 'http://your-proxy:2001',
# # 'model': 'claude-opus-4-6',
# # }
# ══════════════════════════════════════════════════════════════════════════════
# 示例 5 — anyrouter (Claude Code 社区中继;含镜像站)
# ──────────────────────────────────────────────────────────────────────────────
native_claude_config_anyrouter = {
'name': 'anyrouter', # /llms 显示名 & mixin 引用名
'apikey': 'sk-<your-anyrouter-key>', # 非 sk-ant- 前缀 → Bearer 鉴权
'apibase': 'https://<your-anyrouter-mirror-host>', # 镜像站根域名
'model': 'claude-opus-4-6[1m]', # 必须带 [1m],网关强制 1m-beta
'fake_cc_system_prompt': True, # bool 必填 True网关会校验 CC 固定系统串
'thinking_type': 'adaptive', # 'adaptive'/'enabled'/'disabled';必填,不发 thinking 会被拒
# 'reasoning_effort': 'high', # 可选;写进 Claude output_config.effort
'max_retries': 5, # int镜像偶发 503多重试几次
'read_timeout': 300, # int 秒1m 上下文响应可能很慢
# 'max_tokens': 32768, # int 默认 8192
# 'prompt_cache': True, # bool 默认 True
# 'stream': True, # bool 默认 True
}
# 4. 其他 Native 兼容渠道
# ══════════════════════════════════════════════════════════════════════════════
# 示例 6 — claude-relay-service (CRS) 反代 Claude Max
# ──────────────────────────────────────────────────────────────────────────────
# CRS 需要 fake_cc_system_prompt=True
native_claude_config_crs_claude = {
'name': 'crs-claude-max', # /llms 显示名
'apikey': 'cr_<your-crs-claude-key>', # cr_ 开头 → Bearer 鉴权64 位 hex
'apibase': 'https://<your-crs-host>/api',# CRS 的 Anthropic 兼容路径
'model': 'claude-opus-4-6[1m]', # [1m] 触发 1m beta
'fake_cc_system_prompt': True, # bool 必填 TrueCRS 也校验 CC 系统串
'thinking_type': 'adaptive', # 'adaptive'/'enabled'/'disabled'
# 'reasoning_effort': 'high', # 可选;写进 output_config.effort
'max_tokens': 32768, # intCRS 允许大 max_tokens
'max_retries': 3, # int
'read_timeout': 180, # int 秒
}
# ══════════════════════════════════════════════════════════════════════════════
# 示例 7 — CRS 反代 Gemini Ultra (Antigravity 通道)
# ──────────────────────────────────────────────────────────────────────────────
# CRS 把 Google Antigravity (Gemini Ultra) 包装成 Anthropic 风格接口。
# URL 路径带 /antigravity/api
# - 'claude-opus-4-6-thinking' (CRS 原始名)
# - 'claude-opus-4-6[1m]' (触发 1m betaCRS 会忽略多余的 beta)
# - 'claude-opus-4-6' (最简)
native_claude_config_crs_gemini = {
'name': 'crs-gemini-ultra', # /llms 显示名
'apikey': 'cr_<your-crs-gemini-key>', # cr_ 前缀 → Bearer
'apibase': 'https://<your-crs-gemini-host>/antigravity/api', # 特殊的 antigravity 路径
'model': 'claude-opus-4-6-thinking', # 或 'claude-opus-4-6[1m]' 或 'claude-opus-4-6',实测三种等价
# 'fake_cc_system_prompt': True,
# 'thinking_type': 'adaptive', # CRS Gemini 不强制 thinking可留空
'max_tokens': 32768, # int
'max_retries': 3, # int
'read_timeout': 180, # int 秒SSE 偶尔被上游截断
'steam': False # CRS Antigravity 通道不支持 SSE 流式
}
# ══════════════════════════════════════════════════════════════════════════════
# 示例 8 — 智谱 GLM-5.1 (Anthropic 兼容协议)
# ──────────────────────────────────────────────────────────────────────────────
# 智谱提供了 Anthropic 兼容接口 /api/anthropic走 NativeClaudeSession。
# 变量名含 'native' + 'claude' 即可。apikey 是智谱格式 (xxx.yyy)。
native_claude_glm_config = {
'name': 'glm-5.1', # /llms 显示名
'apikey': '<your-zhipu-apikey>', # 形如 f0f1b798xxxx.F8SSbzxxxx非 sk-ant- → Bearer
'apibase': 'https://open.bigmodel.cn/api/anthropic', # 智谱 Anthropic 兼容端点
'model': 'glm-5.1', # 智谱 model id无 [1m] 支持
'max_retries': 3, # int
'connect_timeout': 10, # int 秒
'read_timeout': 180, # int 秒
# 'fake_cc_system_prompt': False, # 智谱不做 CC 指纹校验,保持默认 False
}
# ══════════════════════════════════════════════════════════════════════════════
# 示例 9 — MiniMax (双端点OAI chat/completions + Anthropic Messages)
# ──────────────────────────────────────────────────────────────────────────────
# MiniMax 同时提供 OAI 和 Anthropic 兼容接口,同一个 key 两个端点都能用:
# - /v1 → chat/completions (LLMSession)
# - /anthropic → Anthropic Messages (NativeClaudeSession)
# OAI 路径会返回 <think> 标签M2.7 自带思考Anthropic 路径更简洁。
# ── 4a. MiniMax OAI 路径 (/v1 chat/completions) ────────────────────────────
# OAI 路径会返回 <think> 标签M2.7 自带思考Anthropic 路径更简洁(见 1f
# 温度自动修正为 (0, 1],支持 M2.7/M2.5 全系列204K 上下文。
# MiniMax OAI 路径
oai_config_minimax = {
'name': 'minimax-oai', # /llms 显示名
'apikey': 'sk-<your-minimax-key>', # 形如 sk-cp-xxxxxxxxxBearer 鉴权
'apibase': 'https://api.minimaxi.com/v1', # OAI 兼容端点
'model': 'MiniMax-M2.7', # 模型 id名含 'minimax' 会被 llmcore 把 temp 夹到 (0.01,1.0]
# 'model': 'MiniMax-M2.7-highspeed', # 高速档
'context_win': 50000, # intMiniMax 204K 上下文,此处是裁剪阈值
# 'temperature': 0.7, # 会被自动 clamp 到 (0.01, 1.0]
# 'max_tokens': 8192, # int 默认 8192
# 'max_retries': 3, # int
}
# MiniMax Anthropic 路径(推荐——响应更简洁,无额外 <think> 标签)
# native_claude_config_minimax = {
# 'name': 'minimax-anthropic', # /llms 显示名
# 'apikey': 'sk-<your-minimax-key>', # 与 OAI 路径同一个 key
# 'apibase': 'https://api.minimaxi.com/anthropic', # Anthropic Messages 兼容端点
# 'model': 'MiniMax-M2.7',
# 'max_retries': 3, # int
# # 'fake_cc_system_prompt': False, # MiniMax 不做 CC 指纹校验
# oai_config_minimax = {
# 'name': 'minimax-oai', # /llms 显示名
# 'apikey': 'sk-<your-minimax-key>', # 形如 sk-cp-xxxxxxxxxBearer 鉴权
# 'apibase': 'https://api.minimaxi.com/v1', # OAI 兼容端点
# 'model': 'MiniMax-M2.7', # 名含 'minimax' → temp 夹到 (0.01,1.0]
# 'context_win': 50000, # intMiniMax 204K 上下文,此处是裁剪阈值
# }
# ══════════════════════════════════════════════════════════════════════════════
# 示例 10 — Kimi / Moonshot (OAI 兼容)
# ──────────────────────────────────────────────────────────────────────────────
# ── 4b. Kimi / Moonshot (OAI 兼容) ──────────────────────────────────────────
# 注意Kimi/Moonshot 温度会被 llmcore.py 强制改为 1.0,写什么都会被覆盖。
# oai_config_kimi = {
# 'name': 'kimi-k2', # /llms 显示名
@@ -321,27 +357,20 @@ oai_config_minimax = {
# }
# ══════════════════════════════════════════════════════════════════════════════
# 示例 11 — Mixin 故障转移 (多 session 自动回退)
# ──────────────────────────────────────────────────────────────────────────────
# llm_nos 里的字符串必须和被引用 session 的 'name' 字段匹配(也可以写整数索
# 引)。约束:引用的 session 必须都是 Native 或者都不是 Native不能混。
# mixin_config_claude_fallback = {
# 'llm_nos': ['anyrouter', 'crs-claude-max', 'anthropic-direct'],
# # list元素为其他 session 的 namestr或整数索引
# # 约束:引用的 session 必须全是 Native 或全不是,不能混
# 'max_retries': 8, # int;整个 rotation 的总重试次数上限
# 'base_delay': 1.5, # float 秒指数退避起始延迟retry n 时延迟≈base_delay * 2^n
# 'spring_back': 300, # int 秒;切到备用节点后多久再尝试回到第一个节点
# ── 4c. OpenRouter (OAI 协议多模型中继) ─────────────────────────────────────
# OpenRouter 是最通用的多模型 OAI 中继https://openrouter.ai/api/v1。
# model 名用 provider/model 格式(如 anthropic/claude-opus-4-6
# oai_config_openrouter = {
# 'name': 'openrouter-claude', # /llms 显示名 & mixin 引用名;省略则取 model
# 'apikey': 'sk-or-<your-openrouter-key>', # OpenRouter key 形如 sk-or-xxxBearer 鉴权
# 'apibase': 'https://openrouter.ai/api/v1', # 补齐到 /v1/chat/completions
# 'model': 'anthropic/claude-opus-4-6', # provider/model 格式
# 'max_retries': 3, # int 默认 1
# 'connect_timeout': 10, # int 秒 默认 5最小 1
# 'read_timeout': 120, # int 秒 默认 30最小 5
# }
# ══════════════════════════════════════════════════════════════════════════════
# 示例 12 — Sider (需要额外 pip 包 sider_ai_api)
# ══════════════════════════════════════════════════════════════════════════════
# sider_cookie = 'token=Bearer%20eyJhbGciOiJIUz...'
# ══════════════════════════════════════════════════════════════════════════════
# 全局 HTTP 代理(所有没有单独指定 proxy 的 session 共用)
# ══════════════════════════════════════════════════════════════════════════════