Skip to main content

Official Python SDK for tierproxy — premium multi-provider proxy infrastructure for AI/ML pipelines.

Project description

tierproxy — Python SDK

PyPI version Python versions Downloads CI codecov License: Apache 2.0 OpenAPI 3.1 MCP compatible

Premium multi-provider proxy infrastructure for AI/ML pipelines. Built for engineers who measure cost, latency, and success rate twice — and write Python.

Install

pip install tierproxy

Quickstart — five-second flavor

import tierproxy
r = tierproxy.get("https://example.com", country="US")
print(r.text)

That's it. (Set TIERPROXY_API_KEY env var first.)

Three lines, persistent session

from tierproxy import TierProxy
with TierProxy() as g:
    print(g.me.get().client_id)
    r = g.get("https://example.com", country="US", session_id="s1")

Auto-pick the cheapest healthy upstream every request

g = TierProxy(routing="cheapest")  # also: "fastest", "most_reliable", "balanced"
g.get("https://example.com")     # picks via /v1/health/upstreams under the hood

Cost guardrails + 80% usage alert

def alert(pct: float) -> None:
    print(f"Used {pct:.0f}% of monthly quota")

g = TierProxy(
    monthly_budget_usd=200.0,    # raises BudgetExceededError before going over
    on_usage_pct=80,             # fires the callback once you cross 80%
    on_usage_callback=alert,
)

Power-user knobs

import httpx
from tierproxy import TierProxy
from tierproxy.retry import RetryPolicy

g = TierProxy(
    api_key="tp_live_...",
    base_url="https://my-self-hosted-gw:8444",
    timeout=10.0,
    retry_policy=RetryPolicy(max_retries=5, retry_on_status=frozenset({500, 502})),
    http_client=httpx.Client(verify=False),  # custom transport
    user_agent_suffix="my-app/2.3",          # attribution
)

Raw modes (Playwright, curl, etc.)

from tierproxy import ProxyURL

p = ProxyURL(api_key="tp_live_...", country="US", mode="username_encoding")
print(p.http_url())  # http://customer-tp_live_...-cc-US:x@gw.tierproxy.com:443

How tierproxy compares

tierproxy Smartproxy SDK Bright Data SDK Oxylabs SDK DataImpulse
Multi-provider routing
Client-side smart selector (cost-aware)
Live usage streaming (SSE)
MCP server (Claude/Cursor/Cline)
OpenTelemetry built-in
Sync + async parity partial partial partial partial
AI/ML framework examples shipped 10 0 1 0 0
Type-safe (Pydantic v2 + mypy strict) partial
OpenAPI 3.1 spec
Pip-installable CLI (tierproxy doctor)
License Apache 2.0 proprietary proprietary proprietary proprietary

Features

  • Five-second quickstartimport tierproxy; tierproxy.get(url, country="US")
  • Layered API — five integration levels from one-liner to power-user knobs
  • Smart routingrouting="cheapest" auto-picks healthy upstream per request
  • Cost guardrailsmonthly_budget_usd= refuses requests that would exceed budget
  • Usage alertson_usage_pct=80 fires callback at 80% of quota
  • Live SSE streamfor delta in g.usage.stream() tails month-to-date bytes
  • MCP servertierproxy-mcp exposes proxy as tools to Claude/Cursor/Cline
  • 10 framework integrations — LangChain, LlamaIndex, Crawl4AI, Playwright, Firecrawl, Browser-Use, ScrapeGraphAI, CrewAI, GPT-Researcher
  • OpenTelemetry opt-inpip install tierproxy[otel] for distributed tracing
  • Geo + sticky sessions — countries, cities, 1-1440min session pins
  • Dual URL syntax — headers (httpx/requests) AND username-encoding (Playwright)
  • Type-safe end-to-end — Pydantic v2 models, mypy strict, full IDE autocomplete

See examples/ for LangChain/LlamaIndex/Crawl4AI/Playwright and examples/levels.py for a runnable demo of every level.

Use with your favorite AI/agent framework

Framework Example Notes
LangChain with_langchain.py RAG document loaders through proxy
LlamaIndex with_llamaindex.py SimpleWebPageReader through proxy
Crawl4AI with_crawl4ai.py Playwright crawler + tierproxy
Firecrawl (hot) with_firecrawl.py Self-hosted Firecrawl + residential IPs
Browser-Use (hot) with_browser_use.py LLM-driven autonomous browser
CrewAI (hot) with_crewai.py Multi-agent scraper crew + cost-aware routing
ScrapeGraphAI with_scrapegraphai.py LLM-driven extraction in plain English
GPT-Researcher with_gpt_researcher.py Multi-region research with geo rotation
Playwright with_playwright.py Direct Playwright with tierproxy
MCP (Claude/Cursor/Cline/Windsurf) (unique) mcp_claude_desktop.md Native tool integration via tierproxy-mcp

MCP server (Claude Desktop / Cursor / Cline / Windsurf)

pip install tierproxy[mcp]

Then add to your MCP client config:

{
  "mcpServers": {
    "tierproxy": {
      "command": "tierproxy-mcp",
      "env": { "TIERPROXY_API_KEY": "tp_live_..." }
    }
  }
}

Now your AI assistant can call fetch_url(url, country="US"), inspect health and usage, and route through the cheapest healthy upstream — no glue code, no httpx imports, no boilerplate.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tierproxy-0.1.0.tar.gz (70.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tierproxy-0.1.0-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file tierproxy-0.1.0.tar.gz.

File metadata

  • Download URL: tierproxy-0.1.0.tar.gz
  • Upload date:
  • Size: 70.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tierproxy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fa6d597920f4a1b7112cb52abff7fee2cae59374b485cc89ce568db2bc331389
MD5 3a33a1a485382c4c83155cc305de5637
BLAKE2b-256 2fbb9f5d21c00e16e121d0f2b8ea3ab8d4c20f724749363d7002daa6bba5b076

See more details on using hashes here.

Provenance

The following attestation bundles were made for tierproxy-0.1.0.tar.gz:

Publisher: release.yml on tierproxy/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tierproxy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tierproxy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tierproxy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 052e06af6c8a1fed1b752023452532869282a5d1572aeb1bc53eac18cc18d72d
MD5 64fee562890f3205b0f81f3dfef54d30
BLAKE2b-256 3bd5aedb9572eabf5b71c5d58feea7330643cdf6fae476f3982b510b7cc2597e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tierproxy-0.1.0-py3-none-any.whl:

Publisher: release.yml on tierproxy/python-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page