diff --git a/backend/src/plugins/translate/_llm_async_http.py b/backend/src/plugins/translate/_llm_async_http.py index 3861009a..6389acb7 100644 --- a/backend/src/plugins/translate/_llm_async_http.py +++ b/backend/src/plugins/translate/_llm_async_http.py @@ -117,7 +117,7 @@ async def call_openai_compatible( response, response_text = await _do_http_request(url, headers, payload) await _handle_response_format_fallback(response, response_text, payload, url, headers) - if not response.ok: + if not response.is_success: logger.explore( f"LLM API error status={response.status_code} " f"model={payload.get('model')} " @@ -225,7 +225,7 @@ async def _handle_response_format_fallback( """Handle 400 errors from structured_outputs not being supported.""" _patterns = ("response_format", "structured_outputs", "structured", "json_object") if ( - not response.ok + not response.is_success and response.status_code == 400 and any(p in (response_text or "").lower() for p in _patterns) ):