🚀 Auto-deploy: BotVPS atualizado em 28/04/2026 23:27:49

This commit is contained in:
2026-04-28 23:27:49 +00:00
parent 00622b34aa
commit aeacb372a8

View File

@@ -222,8 +222,17 @@ async def _call_openrouter_async(model: str, prompt: str, system_prompt: str = N
async with httpx.AsyncClient() as client:
res = await client.post(url, json=payload, headers=headers, timeout=120)
if res.status_code == 200:
return res.json()["choices"][0]["message"]["content"]
return f"Erro OpenRouter: {res.status_code} - {res.text}"
data = res.json()
if "choices" in data and len(data["choices"]) > 0:
return data["choices"][0]["message"]["content"]
return f"Erro OpenRouter (Resposta sem 'choices'): {json.dumps(data)}"
# Se não for 200, tenta extrair erro detalhado
try:
error_data = res.json()
return f"Erro OpenRouter {res.status_code}: {json.dumps(error_data)}"
except:
return f"Erro OpenRouter: {res.status_code} - {res.text}"
except Exception as e:
return f"Erro OpenRouter: {str(e)}"