v3.8.5: Add x-codebuff-model and x-codebuff-instance-id headers for codebuff API

This commit is contained in:
2026-05-24 19:06:48 +00:00
Unverified
parent fc694093b5
commit 1c679f9c65

View File

@@ -336,10 +336,11 @@ def _freebuff_get_session(token, model):
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": f"Bearer {token}", "Authorization": f"Bearer {token}",
"User-Agent": "codex-launcher/3.8.4", "User-Agent": "codex-launcher/3.8.4",
"x-freebuff-model": model,
}) })
resp = urllib.request.urlopen(req, timeout=15) resp = urllib.request.urlopen(req, timeout=15)
data = json.loads(resp.read()) data = json.loads(resp.read())
instance_id = data.get("instanceId", "") instance_id = data.get("instanceId", data.get("data", {}).get("instance_id", ""))
expires_at = data.get("remainingMs", 0) expires_at = data.get("remainingMs", 0)
if instance_id: if instance_id:
with _freebuff_token_lock: with _freebuff_token_lock:
@@ -4810,7 +4811,10 @@ class Handler(http.server.BaseHTTPRequestHandler):
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": f"Bearer {token}", "Authorization": f"Bearer {token}",
"User-Agent": "codex-launcher/3.8.4", "User-Agent": "codex-launcher/3.8.4",
"x-freebuff-model": model,
} }
if instance_id:
headers["x-freebuff-instance-id"] = instance_id
print(f"[{self._session_id}] [freebuff] POST {target} model={model} stream={stream} run={run_id}", file=sys.stderr) print(f"[{self._session_id}] [freebuff] POST {target} model={model} stream={stream} run={run_id}", file=sys.stderr)
chat_body_b = json.dumps(chat_body).encode() chat_body_b = json.dumps(chat_body).encode()
@@ -4926,7 +4930,9 @@ class Handler(http.server.BaseHTTPRequestHandler):
if body.get("tool_choice"): if body.get("tool_choice"):
chat_body["tool_choice"] = body["tool_choice"] chat_body["tool_choice"] = body["tool_choice"]
target = f"{_FREEBUFF_API_URL}/api/v1/chat/completions" target = f"{_FREEBUFF_API_URL}/api/v1/chat/completions"
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {token}", "User-Agent": "codex-launcher/3.8.4"} headers = {"Content-Type": "application/json", "Authorization": f"Bearer {token}", "User-Agent": "codex-launcher/3.8.4", "x-freebuff-model": model}
if instance_id:
headers["x-freebuff-instance-id"] = instance_id
print(f"[freebuff] retry POST {target} model={model} stream={stream} run={run_id} (thinking disabled via DeepSeek native)", file=sys.stderr) print(f"[freebuff] retry POST {target} model={model} stream={stream} run={run_id} (thinking disabled via DeepSeek native)", file=sys.stderr)
try: try:
req = urllib.request.Request(target, data=json.dumps(chat_body).encode(), headers=headers) req = urllib.request.Request(target, data=json.dumps(chat_body).encode(), headers=headers)