## TL;DR
To migrate from Smartproxy to AlterLab, install the `alterlab` Python SDK, replace your Smartproxy client initialization with `alterlab.Client("YOUR_API_KEY")`, and update your request calls to use the AlterLab `.scrape()` method. The transition typically takes less than 60 minutes as the REST API and response formats are designed for high compatibility.

## Why migrate?
Many developers migrate because Smartproxy utilizes bandwidth-based proxy billing, which often requires a separate subscription for their scraping API. AlterLab solves this by offering a unified pay-as-you-go model. You pay only for the successful requests you make, with no monthly minimums or subscription requirements.

Both APIs are capable — this guide is for developers prioritizing pay-as-you-go pricing and no subscription requirements. For a deeper dive into the architectural differences, see our [detailed Smartproxy comparison](/vs/smartproxy).

## Prerequisites
Before starting the migration, ensure you have the following:
- An AlterLab account (create one for [free sign-up](/signup)).
- Your AlterLab API key from the dashboard.
- Approximately 5 minutes of development time.

## Step 1: Install the AlterLab SDK
You can interact with AlterLab via a direct REST API using `curl` or `requests`, but the SDK is the fastest way to migrate.

```bash title="Terminal — Install AlterLab"
pip install alterlab
```

For more detailed setup instructions, refer to our [Getting started guide](/docs/quickstart/installation).

<div data-infographic="steps">
  <div data-step data-number="1" data-title="Install SDK" data-description="pip install alterlab"></div>
  <div data-step data-number="2" data-title="Replace API calls" data-description="Swap Smartproxy client for alterlab.Client"></div>
  <div data-step data-number="3" data-title="Update API key" data-description="Replace Smartproxy key with AlterLab key in .env"></div>
  <div data-step data-number="4" data-title="Test and deploy" data-description="Run your existing tests — same response format"></div>
</div>

## Step 2: Replace your API calls
If you were using Smartproxy's proxy gateway or their scraping API, you can replace those blocks with a single AlterLab client.

### Before: Smartproxy Implementation
```python title="before_smartproxy.py"
import requests

# Using the proxy gateway
proxies = {
    'http': 'http://user:pwd@gate.smartproxy.com:PORT',
    'https': 'http://user:pwd@gate.smartproxy.com:PORT'
}
response = requests.get("https://example.com", proxies=proxies)

# OR using the scraping API
api_url = "https://scraper-api.smartproxy.com/v2/scrape"
params = {"url": "https://example.com", "api_key": "YOUR_KEY"}
response = requests.get(api_url, params=params)
```

### After: AlterLab Implementation
```python title="after_alterlab.py" {3-7}
import alterlab

# Initialize the client once
client = alterlab.Client("YOUR_ALTERLAB_API_KEY")

# Single call handles rotation, anti-bot, and proxying
response = client.scrape("https://example.com")

print(response.text)  # Same data, pay-as-you-go pricing
```

## Step 3: Handle response format differences
AlterLab returns a response object that mimics the standard `requests` library response. If your existing code uses `.text`, `.json()`, or `.status_code`, it will work without modification.

One key difference is that AlterLab handles the "tiering" (the level of proxy/browser needed) automatically. If you encounter a site with heavy bot protection, you can simply add the `min_tier` parameter:

```python title="tier_example.py"
# Force JavaScript rendering for complex sites
response = client.scrape("https://example.com", min_tier=3)
```

## Step 4: Update your error handling
Smartproxy and AlterLab use similar HTTP status codes for most errors (403 for Forbidden, 429 for Rate Limited). However, ensure your retry logic is updated to handle AlterLab's specific balance errors.

If your account balance reaches zero, AlterLab will return a specific error indicating insufficient balance. Since there is no monthly subscription, you simply top up your balance to resume service.

## Cost comparison
The primary driver for this migration is the billing model. Smartproxy's bandwidth-based pricing can be unpredictable if your page sizes vary. AlterLab uses a request-based model.

**Example: 10,000 successful requests**
- **Smartproxy**: Cost varies based on GB of bandwidth used + separate API subscription fee.
- **AlterLab**: 10,000 requests $\times$ $0.0002 = $2.00 (approximate, depending on tier).

<div data-infographic="stats">
  <div data-stat data-value="$0.0002" data-label="Per Request (AlterLab)"></div>
  <div data-stat data-value="$0" data-label="Monthly Minimum"></div>
  <div data-stat data-value="Never" data-label="Balance Expiry"></div>
</div>

Check the full [AlterLab pricing](/pricing) page for current rates across different tiers.

## Common issues and fixes
- **SSL Errors**: If you are using a corporate proxy, ensure your environment variables are not overriding the AlterLab SDK's internal connection.
- **Timeout Settings**: AlterLab's automatic anti-bot bypass may take slightly longer than a raw proxy request. Increase your `timeout` parameter to 30 seconds for high-tier scrapes.
- **Header Mismatches**: AlterLab automatically manages User-Agents. If you were manually setting `User-Agent` in Smartproxy, try removing it first to let AlterLab's optimization engine handle the fingerprinting.

## You're done
Your migration is complete. You now have a pay-as-you-go scraping pipeline with no recurring monthly costs. For more advanced features like scheduling or AI extraction, visit our [documentation](/docs).