The SDK includes automatic retry handling with exponential backoff to enhance reliability. A request will be retried if it meets the following conditions:
- The response status code indicates a retriable error.
- The number of retry attempts is less than the configured retry limit (default:
2
).
The following status codes are considered retriable:
You can customize the retry behavior using the max_retries
option in request_options
.
client.query(
query="Tell me about AI.",
request_options={"max_retries": 3} # Configure the maximum number of retries
)
The SDK applies a default timeout of 60 seconds for all requests. You can adjust this timeout globally at the client level or for specific API calls.
Set the timeout for all SDK operations when initializing the client:
from vectara import Vectara
client = Vectara(
...,
timeout=30.0 # Set a 30-second timeout for all requests
)
Customize the timeout for individual API calls using request_options
:
client.query(
query="Tell me about AI.",
request_options={"timeout_in_seconds": 10} # Set a 10-second timeout for this request
)
The SDK allows you to provide a custom httpx.Client
to fine-tune network configurations, such as:
- Using a proxy server.
- Specifying a local transport address.
import httpx
from vectara import Vectara
client = Vectara(
...,
httpx_client=httpx.Client(
proxies="http://proxy.example.com:8080",
transport=httpx.HTTPTransport(local_address="192.168.1.100"),
)
)