diff --git a/autogen/oai/client.py b/autogen/oai/client.py index 70a28e15ed6..147f412fd87 100644 --- a/autogen/oai/client.py +++ b/autogen/oai/client.py @@ -248,12 +248,16 @@ def yes_or_no_filter(context, response): continue # filter is not passed; try the next config try: response = self._completions_create(client, params) - except APIError: + except APIError as err: + error_code = getattr(err, "code", None) + if error_code == "content_filter": + # raise the error for content_filter + raise logger.debug(f"config {i} failed", exc_info=1) if i == last: raise else: - # add cost calculation before caching not matter filter is passed or not + # add cost calculation before caching no matter filter is passed or not response.cost = self.cost(response) self._update_usage_summary(response, use_cache=False) if cache_seed is not None: