ProxAIAdvanced FeaturesSuppress Provider Errors

Suppress Provider Errors

The suppress_provider_errors parameter is used to suppress provider errors. This is useful when you want to continue the execution of your code even if some providers are down or experiencing quota issues.

  • By default, this feature is disabled.

To get more information about errors, you can set the extensive_return parameter to True in the px.generate_text() function. This will return a LoggingRecord object with the error and traceback if an error occurs.

px.connect(suppress_provider_errors=True)
 
response = px.generate_text(
  prompt="Hello model!",
  extensive_return=True,
)
print('response:', response.response_record.response)
print('error:', response.response_record.error)
print('error_traceback:', response.response_record.error_traceback)

No error case stdout:

response: Hello! How can I assist you today?
error: None
error_traceback: None

Error case stdout:

response: None
error: 404 Gemini 1.0 Pro will be discontinued on February 15th, 2025. Move to a newer Gemini version.
error_traceback: Traceback (most recent call last):
  ...
  File "/usr/local/lib/python3.11/dist-packages/google/api_core/retry/retry_unary.py", line 144, in retry_target
    result = target()
             ^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/google/api_core/timeout.py", line 120, in func_with_timeout
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/google/api_core/grpc_helpers.py", line 78, in error_remapped_callable
    raise exceptions.from_grpc_error(exc) from exc
google.api_core.exceptions.NotFound: 404 Gemini 1.0 Pro will be discontinued on February 15th, 2025. Move to a newer Gemini version.

Suppress Provider Errors Usage

There are two ways to suppress provider errors:

  1. Setting the config in the px.connect() function
  2. Setting the config in the px.generate_text() function

Option 1: px.connect() function

It is possible to set the suppress_provider_errors parameter in the px.connect() function. This will suppress provider errors for all subsequent calls in the current session.

px.connect(suppress_provider_errors=True)

See the connect page for all parameters.

Option 2: px.generate_text() function

It is possible to set the suppress_provider_errors parameter in the px.generate_text() function. This will suppress provider errors for that specific call only.

response = px.generate_text(
  prompt="Hello model!",
  suppress_provider_errors=True,
)

See the generate_text page for all parameters.