Reset State
Use these functions with caution. They will reset all configurations and platform cache.
ProxAI maintains internal state including configuration options, platform cache, and other settings. There are times when you need to completely reset this state, such as when switching between projects or testing different configurations.
Reset All State
The px.reset_state()
function performs a hard reset on all ProxAI options and clears the platform cache:
import proxai as px
# Set up ProxAI with specific options
px.connect(
cache_path='~/proxai-cache',
logging_path='~/proxai-logs')
# Do some work with ProxAI...
# Reset everything to defaults and clear platform cache
px.reset_state()
# After reset, you can reconnect or directly use ProxAI functions as newly imported module
px.connect()
What Gets Reset
When you call px.reset_state()
, the following state is reset:
- All options set via
px.connect()
are reset to their default values - Platform cache (model availability data) is cleared
- Internal state trackers are reset
This is equivalent to restarting your Python process and reimporting ProxAI, but without actually needing to restart.
Reset Platform Cache Only
If you only need to refresh the model availability cache without resetting all options, you can use px.reset_platform_cache()
:
import proxai as px
# List available models (this builds and caches the model list)
available_models = px.models.list_models()
# If you think the cache needs to be deleted (most of the time you don't need to do this)
px.reset_platform_cache()
# Now list_models() will rebuild the cache with fresh data
updated_models = px.models.list_models()
Platform Cache Details
By default, this cache is stored in a temporary location and persists for four hours to avoid unnecessary API calls to provider services. The cache improves performance by:
- Speeding up
px.models.list_models()
calls - Preventing repeated provider API calls to check model availability
- Remembering which models have failed tests
Better Alternatives
In most cases, you don’t need to use these low-level reset functions. The model functions have built-in options that are easier to use and more targeted.
For most common scenarios, there are better alternatives to using the reset functions directly.
Instead of calling px.reset_platform_cache()
, use the clear_model_cache
parameter with model functions:
# This is the recommended approach - it specifically refreshes the model cache
models = px.models.list_models(clear_model_cache=True)
claude_models = px.models.list_provider_models(provider='claude', clear_model_cache=True)
model = px.models.get_model(provider='openai', model='gpt-4o', clear_model_cache=True)
For more details on model functions and their parameters, see the Available Models documentation.