Skip to main content

Timeout Configuration

Model training and rollout operations can be long-running. Configure timeouts to match your workload:
from aibread import Bread
import httpx

# Simple timeout (seconds)
client = Bread(timeout=20.0)

# Granular control
client = Bread(
    timeout=httpx.Timeout(
        60.0,         # Total timeout
        connect=2.0,  # Connection timeout
        read=5.0,     # Read timeout
        write=10.0    # Write timeout
    )
)

Retry Configuration

The SDK automatically retries transient errors (408, 409, 429, 5xx) with exponential backoff and jitter.
from aibread import Bread

# Default is 2 retries. Increase for high-concurrency workloads:
client = Bread(max_retries=5)

# Disable retries entirely:
client = Bread(max_retries=0)

Async Performance

For high-performance applications managing multiple repositories or bakes concurrently, use the async client.
import asyncio
from aibread import AsyncBread

async def main():
    async with AsyncBread() as client:
        # Run multiple operations in parallel
        repos = await client.repo.list()
        print(repos)

asyncio.run(main())

Custom HTTP Client & Proxies

Configure custom transports, proxies, or SSL certificates:
import httpx
from aibread import Bread, DefaultHttpxClient

client = Bread(
    http_client=DefaultHttpxClient(
        proxy="http://my-proxy.com:8080",
        transport=httpx.HTTPTransport(local_address="0.0.0.0")
    )
)

Raw Response Access

Access the underlying HTTP response metadata when you need to inspect headers or status codes directly:
# Use .with_raw_response
response = client.repo.with_raw_response.list()

print(response.status_code)
print(response.headers.get('X-Custom-Header'))

# Parse to get the typed data
repos = response.parse()