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