Client
px.connect() configures a default global client. If you need multiple independent
clients with different configurations, use px.Client() directly.
Simple Config
import proxai as px
client = px.Client(
experiment_path='translation/en-to-fr/experiment_1',
feature_mapping_strategy=px.types.FeatureMappingStrategy.STRICT)
response = client.generate_text(prompt="Hello, world!")More Customized Config
import proxai as px
client = px.Client(
experiment_path='translation/en-to-fr/experiment_1',
logging_options=px.LoggingOptions(
logging_path='~/proxai-logs',
stdout=True,
hide_sensitive_content=True),
cache_options=px.CacheOptions(
cache_path=
Difference Between px.connect() and px.Client()
px.connect() is simply an alias that configures the default global client.
When you call px.generate_text(), it uses this global client internally.
Use px.Client() when you need multiple clients with different configurations
running simultaneously.
import proxai as px
# Configure default global client
px.connect()
px.set_model(('openai', 'gpt-4'))
# Create a separate client instance
client = px.Client()
client.set_model(('anthropic', 'claude-sonnet'))
# Use both clients
response1 = px.generate_text(prompt="Hello!", extensive_return=
(openai, gpt-4)
(anthropic, claude-sonnet)Parameters
px.Client() accepts the same parameters as px.connect():
| Option | Type | Default Value | Description |
|---|---|---|---|
experiment_path | str | None | Path of the experiment for this client. |
cache_options | px.types.CacheOptions | None | Cache options for this client. |
logging_options | px.types.LoggingOptions | None | Logging options for this client. See, page. |