docs: 重写 gaccode API 配置指南,更新 key 和模型列表

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dsa343
2026-03-19 11:00:14 +08:00
parent f11dc58530
commit 01ff7766c4

View File

@@ -1,146 +1,128 @@
#价值前沿 # 价值前沿 — GACCODE Claude API 配置指南
【公司提供的Claude Code API】 ## API Key
Claude Code API: 当前有效:
sk-ant-oat01-d0e6f8c0cd9d87d4efd0aa164f143571454c678127c7daf8ff5ba3916282b23e
sk-ant-oat01-357ef209755a2161be80cd052ebe3985ce3b8aba15d78d84e9b07910a0966b69已废弃
已废弃:
sk-ant-oat01-357ef209755a2161be80cd052ebe3985ce3b8aba15d78d84e9b07910a0966b69
sk-ant-oat01-d255ca887a1d5b8fd4fa7f37d59cc34cf81c017602acaf27321e6f361a7709bc sk-ant-oat01-d255ca887a1d5b8fd4fa7f37d59cc34cf81c017602acaf27321e6f361a7709bc
GACCODE 完整请求体 1. HTTP请求格式
POST https://154.26.181.99/claudecode/v1/messages ## 连接方式
IP 直连源站,绕过 Cloudflare。必须满足:
- SSL 验证关闭 (verify=False / -k)
- Host 头设为 gaccode.com
- 禁用本地代理 (清除 HTTP_PROXY / HTTPS_PROXY)
端点: POST https://154.26.181.99/claudecode/v1/messages
2. 请求头Headers ## 请求头
{ {
"anthropic-version": "2023-06-01", "anthropic-version": "2023-06-01",
"content-type": "application/json", "content-type": "application/json",
"x-api-key": "<你的 API Key>",
"x-api-key": "sk-ant-oat01-xxxxxxxx...",
"Host": "gaccode.com" "Host": "gaccode.com"
} }
说明因为是IP直连源站绕过Cloudflare需要手动设置 Host: gaccode.com ## 请求体
让后端nginx/openresty正确路由。SSL验证需要关闭verify_ssl: False
3. 请求体Payload
{ {
"model": "claude-sonnet-4-20250514",
"model": "claude-opus-4-5-20250514", "max_tokens": 8192,
"max_tokens": 32000,
"temperature": 0.7, "temperature": 0.7,
"messages": [ "messages": [
{"role": "user", "content": "你的提示词内容..."}
{
"role": "user",
"content": "你的提示词内容..."
}
], ],
"stream": false
"stream": true
} }
可选字段:
- "system": "系统提示词"
- "stream": true (流式输出,需自行解析 SSE)
可用模型 (按价格从低到高):
- claude-haiku-4-5-20251001
- claude-sonnet-4-20250514
- claude-sonnet-4-6-20250627
- claude-opus-4-5-20250514
- claude-opus-4-6-20250617
可选字段: ## 响应格式
{ {
"id": "msg_xxx",
"system": "系统提示词(可选)", "model": "claude-sonnet-4-20250514",
"content": [
"thinking": { {"type": "text", "text": "回答内容..."}
],
"type": "enabled", "stop_reason": "end_turn",
"usage": {
"budget_tokens": 10000 "input_tokens": 1828,
"output_tokens": 2,
"cache_creation_input_tokens": 228,
"cache_read_input_tokens": 0
}
} }
} ## curl 示例
注意thinking 参数是否被gaccode代理支持尚未验证。根据之前的测试gaccode代理以文本方式返回thinking内容包裹在<thinking>标签
说明代理可能不完整支持thinking协议。
4. curl 完整示例
curl -k -X POST "https://154.26.181.99/claudecode/v1/messages" \ curl -k -X POST "https://154.26.181.99/claudecode/v1/messages" \
-H "anthropic-version: 2023-06-01" \ -H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \ -H "content-type: application/json" \
-H "x-api-key: sk-ant-oat01-d0e6f8c0cd9d87d4efd0aa164f143571454c678127c7daf8ff5ba3916282b23e" \
-H "x-api-key: sk-ant-oat01-8625cbcbf200d225488cbfcf952f44bf66fac7089f01dd6c336e1b6699939306" \
-H "Host: gaccode.com" \ -H "Host: gaccode.com" \
-d '{ -d '{
"model": "claude-sonnet-4-20250514",
"model": "claude-opus-4-5-20250514", "max_tokens": 8192,
"max_tokens": 32000,
"temperature": 0.7,
"messages": [{"role": "user", "content": "Hello"}], "messages": [{"role": "user", "content": "Hello"}],
"stream": false
"stream": true
}' }'
## Python 示例 (httpx)
import httpx, os
响应格式 # 禁用代理
os.environ.pop("HTTP_PROXY", None)
os.environ.pop("HTTPS_PROXY", None)
{ client = httpx.Client(verify=False, timeout=300.0)
response = client.post(
"https://154.26.181.99/claudecode/v1/messages",
headers={
"anthropic-version": "2023-06-01",
"content-type": "application/json",
"x-api-key": "sk-ant-oat01-d0e6f8c0cd9d87d4efd0aa164f143571454c678127c7daf8ff5ba3916282b23e",
"Host": "gaccode.com",
},
json={
"model": "claude-sonnet-4-20250514",
"max_tokens": 8192,
"messages": [{"role": "user", "content": "Hello"}],
"stream": False,
},
)
print(response.json())
"id": "msg_xxx", ## 关键约束
"model": "claude-opus-4-6", 1. 并发上限: 3
2. 超时建议: 300-600 秒
3. 必须禁用代理 (proxies=None 或清除环境变量)
4. 必须关闭 SSL 验证 (IP 直连无有效证书)
5. 必须设置 Host: gaccode.com (nginx 路由依赖)
"content": [ ## 错误码
{"type": "thinking", "thinking": "内部推理过程..."}, - 402 Payment Required: API Key 余额不足或已过期,需更换 Key
- 429 Too Many Requests: 并发超限,降低并发或加延迟
- 529 Overloaded: 上游 Claude 过载,等待重试
{"type": "text", "text": "最终回答..."} ## 重试策略 (已验证可靠)
], - HTTP 错误 (402/429/5xx): 重试间隔 10s → 30s → 60s
- 连接断开 (RemoteProtocolError): 重建 httpx.Client间隔 5s → 15s → 30s
"stop_reason": "end_turn", - 最多重试 3 次
"usage": {"input_tokens": 139, "output_tokens": 2269}
}
关键约束
1. 必须绕过代理: proxies={"http": None, "https": None} 或 --proxy ""
2. 并发上限: 3
3. 超时建议: 300-600秒
4. thinking.budget_tokens 不能超过 max_tokens