fix: move _set_usage_and_cost outside try/except in OpenRouter image edit

Prevents discarding already-parsed images when usage calculation fails.
This commit is contained in:
Chesars 2026-03-03 15:58:23 -03:00
parent 6f74d3881a
commit 4b1389501d

View file

@ -242,9 +242,6 @@ class OpenRouterImageEditConfig(BaseImageEditConfig):
)
)
self._set_usage_and_cost(model_response, response_json, model)
return model_response
except Exception as e:
raise OpenRouterException(
message=f"Error transforming OpenRouter image edit response: {str(e)}",
@ -252,6 +249,9 @@ class OpenRouterImageEditConfig(BaseImageEditConfig):
headers={},
)
self._set_usage_and_cost(model_response, response_json, model)
return model_response
def get_error_class(
self, error_message: str, status_code: int, headers: Union[dict, httpx.Headers]
) -> BaseLLMException: