Switchlane Python SDK
A typed sync and async client for the Switchlane runtime routing API.
Switchlane is a decision layer for multi-agent systems, not an agent marketplace or agent-building framework. It routes each task to an eligible agent or MCP-backed service and can abstain instead of returning a weak match.
Install
pip install switchlane
Connect
from switchlane import Switchlane
client = Switchlane(
"sl_live_...",
base_url="http://localhost:3001", # Your self-hosted or managed endpoint
)
The following sync examples reuse this client. Call client.close() when your application shuts down, or use Switchlane as a context manager.
Route a task
result = client.route("Review this pull request")
if result.meta.abstained:
print("No suitable agent:", result.meta.abstention_reason)
else:
print(result.recommendations[0])
Set routing constraints
from switchlane import RouteConstraints
result = client.route(
"Analyze this dataset",
constraints=RouteConstraints(
max_cost_usd=0.05,
max_latency_ms=2_000,
min_quality_score=0.7,
min_routing_confidence=0.5,
),
limit=3,
)
Async client
import asyncio
from switchlane import AsyncSwitchlane
async def main() -> None:
async with AsyncSwitchlane(
"sl_live_...",
base_url="http://localhost:3001",
) as client:
result = await client.route("Research current browser automation tools")
print(result.meta)
asyncio.run(main())
Route and execute
Execution is opt-in and currently supports MCP endpoints. Treat third-party agents and MCP servers as untrusted infrastructure.
result = client.execute(
"Send the deployment result to Slack",
{"channel": "#engineering", "message": "Deployment succeeded"},
)
print(result.execution)
Errors
from switchlane import SwitchlaneError
try:
client.route("Example task")
except SwitchlaneError as error:
print(error.status_code, error, error.body)
Links
License
MIT © Troia Labs. The Switchlane server is licensed separately under AGPL-3.0-only.
Release files for switchlane 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| switchlane-0.1.1.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| switchlane-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.4 kB
Release files / switchlane-0.1.1.tar.gz
| Download URL | switchlane-0.1.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ed229312d26f7b0484604589d21197ef39b803c176a04e52750512034133c40
|
|
BLAKE2b-256 checksum How to use checksums |
0e050db1f5fcbdcf9c63523033ace28839311efd41ffdcb699bdc1d00e683376
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|
Release files / switchlane-0.1.1-py3-none-any.whl
| Download URL | switchlane-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
092616d5239afceda3c0961eb905886435c04c5f4f21705c98e5f3d7ad5e2dbf
|
|
BLAKE2b-256 checksum How to use checksums |
81b76e09a1b59f89a1ce8e92a2b3274f0fa12721a53b0ac43c76f07afdbc47d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|