fix(tools): handle 402 insufficient credits error in vision tool (#2802)

Co-authored-by: Dilee <uzmpsk.dilekakbas@gmail.com>
This commit is contained in:
Teknium
2026-03-24 07:23:07 -07:00
committed by GitHub
parent 98b5570961
commit 2233f764af

View File

@@ -375,6 +375,13 @@ async def vision_analyze_tool(
# so it can inform the user instead of a cryptic API error.
err_str = str(e).lower()
if any(hint in err_str for hint in (
"402", "insufficient", "payment required", "credits", "billing",
)):
analysis = (
"Insufficient credits or payment required. Please top up your "
f"API provider account and try again. Error: {e}"
)
elif any(hint in err_str for hint in (
"does not support", "not support image", "invalid_request",
"content_policy", "image_url", "multimodal",
"unrecognized request argument", "image input",