From 0039f6c12a298944c14ae7cb421558d9be7e4086 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 24 May 2026 19:06:48 +0000 Subject: [PATCH] v3.8.5: Add x-codebuff-model and x-codebuff-instance-id headers for codebuff API --- translate-proxy.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/translate-proxy.py b/translate-proxy.py index 4f93e85..d183e0e 100755 --- a/translate-proxy.py +++ b/translate-proxy.py @@ -336,10 +336,11 @@ def _freebuff_get_session(token, model): "Content-Type": "application/json", "Authorization": f"Bearer {token}", "User-Agent": "codex-launcher/3.8.4", + "x-freebuff-model": model, }) resp = urllib.request.urlopen(req, timeout=15) 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) if instance_id: with _freebuff_token_lock: @@ -4810,7 +4811,10 @@ class Handler(http.server.BaseHTTPRequestHandler): "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"[{self._session_id}] [freebuff] POST {target} model={model} stream={stream} run={run_id}", file=sys.stderr) chat_body_b = json.dumps(chat_body).encode() @@ -4926,7 +4930,9 @@ class Handler(http.server.BaseHTTPRequestHandler): if body.get("tool_choice"): chat_body["tool_choice"] = body["tool_choice"] 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) try: req = urllib.request.Request(target, data=json.dumps(chat_body).encode(), headers=headers)