docs: 重写 gaccode API 配置指南,更新 key 和模型列表
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
264
gaccode.txt
264
gaccode.txt
@@ -1,146 +1,128 @@
|
||||
#价值前沿
|
||||
# 价值前沿 — GACCODE Claude API 配置指南
|
||||
|
||||
【公司提供的Claude Code API】
|
||||
## API Key
|
||||
|
||||
Claude Code API:
|
||||
|
||||
sk-ant-oat01-357ef209755a2161be80cd052ebe3985ce3b8aba15d78d84e9b07910a0966b69(已废弃)
|
||||
当前有效:
|
||||
sk-ant-oat01-d0e6f8c0cd9d87d4efd0aa164f143571454c678127c7daf8ff5ba3916282b23e
|
||||
|
||||
已废弃:
|
||||
sk-ant-oat01-357ef209755a2161be80cd052ebe3985ce3b8aba15d78d84e9b07910a0966b69
|
||||
sk-ant-oat01-d255ca887a1d5b8fd4fa7f37d59cc34cf81c017602acaf27321e6f361a7709bc
|
||||
GACCODE 完整请求体 1. HTTP请求格式
|
||||
|
||||
POST https://154.26.181.99/claudecode/v1/messages
|
||||
|
||||
|
||||
|
||||
2. 请求头(Headers)
|
||||
|
||||
{
|
||||
|
||||
"anthropic-version": "2023-06-01",
|
||||
|
||||
"content-type": "application/json",
|
||||
|
||||
"x-api-key": "sk-ant-oat01-xxxxxxxx...",
|
||||
|
||||
"Host": "gaccode.com"
|
||||
|
||||
}
|
||||
|
||||
说明:因为是IP直连源站(绕过Cloudflare),需要手动设置 Host: gaccode.com
|
||||
|
||||
让后端nginx/openresty正确路由。SSL验证需要关闭(verify_ssl: False)。
|
||||
|
||||
|
||||
|
||||
3. 请求体(Payload)
|
||||
|
||||
{
|
||||
|
||||
"model": "claude-opus-4-5-20250514",
|
||||
|
||||
"max_tokens": 32000,
|
||||
|
||||
"temperature": 0.7,
|
||||
|
||||
"messages": [
|
||||
|
||||
{
|
||||
|
||||
"role": "user",
|
||||
|
||||
"content": "你的提示词内容..."
|
||||
|
||||
}
|
||||
|
||||
],
|
||||
|
||||
"stream": true
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
可选字段:
|
||||
|
||||
{
|
||||
|
||||
"system": "系统提示词(可选)",
|
||||
|
||||
"thinking": {
|
||||
|
||||
"type": "enabled",
|
||||
|
||||
"budget_tokens": 10000
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
注意:thinking 参数是否被gaccode代理支持尚未验证。根据之前的测试,gaccode代理以文本方式返回thinking内容(包裹在<thinking>标签
|
||||
|
||||
中),说明代理可能不完整支持thinking协议。
|
||||
|
||||
|
||||
|
||||
4. curl 完整示例
|
||||
|
||||
curl -k -X POST "https://154.26.181.99/claudecode/v1/messages" \
|
||||
|
||||
-H "anthropic-version: 2023-06-01" \
|
||||
|
||||
-H "content-type: application/json" \
|
||||
|
||||
-H "x-api-key: sk-ant-oat01-8625cbcbf200d225488cbfcf952f44bf66fac7089f01dd6c336e1b6699939306" \
|
||||
|
||||
-H "Host: gaccode.com" \
|
||||
|
||||
-d '{
|
||||
|
||||
"model": "claude-opus-4-5-20250514",
|
||||
|
||||
"max_tokens": 32000,
|
||||
|
||||
"temperature": 0.7,
|
||||
|
||||
"messages": [{"role": "user", "content": "Hello"}],
|
||||
|
||||
"stream": true
|
||||
|
||||
}'
|
||||
|
||||
|
||||
|
||||
响应格式
|
||||
|
||||
{
|
||||
|
||||
"id": "msg_xxx",
|
||||
|
||||
"model": "claude-opus-4-6",
|
||||
|
||||
"content": [
|
||||
|
||||
{"type": "thinking", "thinking": "内部推理过程..."},
|
||||
|
||||
{"type": "text", "text": "最终回答..."}
|
||||
|
||||
],
|
||||
|
||||
"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
|
||||
## 连接方式
|
||||
|
||||
IP 直连源站,绕过 Cloudflare。必须满足:
|
||||
- SSL 验证关闭 (verify=False / -k)
|
||||
- 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": "<你的 API Key>",
|
||||
"Host": "gaccode.com"
|
||||
}
|
||||
|
||||
## 请求体
|
||||
|
||||
{
|
||||
"model": "claude-sonnet-4-20250514",
|
||||
"max_tokens": 8192,
|
||||
"temperature": 0.7,
|
||||
"messages": [
|
||||
{"role": "user", "content": "你的提示词内容..."}
|
||||
],
|
||||
"stream": false
|
||||
}
|
||||
|
||||
可选字段:
|
||||
- "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",
|
||||
"model": "claude-sonnet-4-20250514",
|
||||
"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
|
||||
}
|
||||
}
|
||||
|
||||
## curl 示例
|
||||
|
||||
curl -k -X POST "https://154.26.181.99/claudecode/v1/messages" \
|
||||
-H "anthropic-version: 2023-06-01" \
|
||||
-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,
|
||||
"messages": [{"role": "user", "content": "Hello"}],
|
||||
"stream": false
|
||||
}'
|
||||
|
||||
## 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())
|
||||
|
||||
## 关键约束
|
||||
|
||||
1. 并发上限: 3
|
||||
2. 超时建议: 300-600 秒
|
||||
3. 必须禁用代理 (proxies=None 或清除环境变量)
|
||||
4. 必须关闭 SSL 验证 (IP 直连无有效证书)
|
||||
5. 必须设置 Host: gaccode.com (nginx 路由依赖)
|
||||
|
||||
## 错误码
|
||||
|
||||
- 402 Payment Required: API Key 余额不足或已过期,需更换 Key
|
||||
- 429 Too Many Requests: 并发超限,降低并发或加延迟
|
||||
- 529 Overloaded: 上游 Claude 过载,等待重试
|
||||
|
||||
## 重试策略 (已验证可靠)
|
||||
|
||||
- HTTP 错误 (402/429/5xx): 重试间隔 10s → 30s → 60s
|
||||
- 连接断开 (RemoteProtocolError): 重建 httpx.Client,间隔 5s → 15s → 30s
|
||||
- 最多重试 3 次
|
||||
|
||||
Reference in New Issue
Block a user