Feature Mapping Strategy
ProxAI unifies API calls across different providers and models. However, some providers and models have different feature sets and may not support certain parameters.
The feature_mapping_strategy parameter controls how ProxAI handles these
incompatibilities.
BEST_EFFORT (Default)
With BEST_EFFORT, ProxAI will try to make the request work even if some
features are not supported by the model. Unsupported parameters are silently
ignored.
import proxai as px
px.connect(
feature_mapping_strategy=px.types.FeatureMappingStrategy.BEST_EFFORT)
# o3-mini doesn't support max_tokens, but this will still work
response = px.generate_text(
prompt='What is the capital of France?',
provider_model=('openai', 'o3-mini'),
max_tokens=2000)
print(response)The capital of France is Paris.The max_tokens parameter is ignored since o3-mini doesn’t support it,
but the request succeeds.
STRICT
With STRICT, ProxAI will raise an error if a feature is not supported by
the provider or model. This is useful when you need to ensure exact behavior
across different models.
import proxai as px
px.connect(
feature_mapping_strategy=px.types.FeatureMappingStrategy.STRICT)
# This will raise an error because o3-mini doesn't support max_tokens
response = px.generate_text(
prompt='What is the capital of France?',
provider_model=('openai', 'o3-mini'),
max_tokens=2000)...
--> 241 raise Exception(message)
242 else:
243 logging_utils.log_message(
Exception: o3-mini does not support max tokens.Per-Request Override
You can also set the strategy per request using the feature_mapping_strategy
parameter in generate_text():
import proxai as px
# Default is BEST_EFFORT
px.connect()
# Override to STRICT for this specific request
response = px.generate_text(
prompt='What is the capital of France?',
provider_model=('openai', 'o3-mini'),
max_tokens=2000,
feature_mapping_strategy=px.types.FeatureMappingStrategy.STRICT)