HTTP 503 Service Unavailable Sherlog: TraceID: 0x9125375081d201d2 Headers: {"Alt...
错误信息
Trajectory ID: 42b3949a-c340-4969-abe2-1477f2b1b457
Error: HTTP 503 Service Unavailable
Sherlog:
TraceID: 0x9125375081d201d2
Headers: {"Alt-Svc":["h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000"],"Content-Length":["525"],"Content-Type":["text/event-stream"],"Date":["Mon, 27 Apr 2026 06:34:03 GMT"],"Server":["ESF"],"Server-Timing":["gfet4t7; dur=1256"],"Vary":["Origin","X-Origin","Referer"],"X-Cloudaicompanion-Trace-Id":["9125375081d201d2"],"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["SAMEORIGIN"],"X-Xss-Protection":["0"]}
{
"error": {
"code": 503,
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"domain": "cloudcode-pa.googleapis.com",
"metadata": {
"model": "gemini-3.1-pro-high"
},
"reason": "MODEL_CAPACITY_EXHAUSTED"
},
{
"@type": "type.googleapis.com/google.rpc.RetryInfo",
"retryDelay": "56s"
}
],
"message": "No capacity available for model gemini-3.1-pro-high on the server",
"status": "UNAVAILABLE"
}
}
AI 解决方案
报错分析报告
1.错误翻译
原文:HTTP 503 Service Unavailable;No capacity available for model gemini-3.1-pro-high on the server
译文:HTTP 503 服务不可用;服务器上没有gemini-3.1-pro-high模型的可用容量
2.原因分析
gemini-3.1-pro-high模型服务器容量耗尽(MODEL_CAPACITY_EXHAUSTED),无法分配资源处理请求。 3.解决方案
采用带延迟重试的策略(基于返回的
retryDelay: 56s): import time
import requests
def call_model_with_retry(url, payload, max_retries=3):
retries = 0
while retries < max_retries:
try:
resp = requests.post(url, json=payload, timeout=10)
if resp.status_code == 200:
return resp.json()
elif resp.status_code == 503:
# 解析重试延迟(默认56s)
retry_delay = 56
details = resp.json().get("error", {}).get("details", [])
for d in details:
if d.get("@type") == "type.googleapis.com/google.rpc.RetryInfo":
retry_delay = int(d.get("retryDelay", "56s").rstrip("s"))
break
print(f"容量不足,{retry_delay}秒后重试(第{retries+1}次)...")
time.sleep(retry_delay)
retries += 1
else:
raise Exception(f"非预期状态码: {resp.status_code}")
except Exception as e:
print(f"请求失败: {e}")
retries += 1
time.sleep(10) # 短暂等待后重试
raise Exception("超过最大重试次数")
# 使用示例
url = "https://your-model-endpoint" # 替换为实际接口
payload = {"model": "gemini-3.1-pro-high", "input": "你的请求内容"}
result = call_model_with_retry(url, payload)
4. 预防措施
retryDelay动态调整。 tenacity库简化重试逻辑;前端用axios-retry插件。---
以上方案直接解决容量耗尽导致的503错误,需根据实际语言调整实现。