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 © Ekrem Aksoy. The Switchlane server is licensed separately under AGPL-3.0-only.
Release files for switchlane 0.1.2
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.2.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| switchlane-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.4 kB
Release files / switchlane-0.1.2.tar.gz
| Download URL | switchlane-0.1.2.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
811525e11d3ec32d6548257a9c5be217b32987253af0c42d6c3c64c286f54fbd
|
|
BLAKE2b-256 checksum How to use checksums |
5b41ad5eaf19fce99a3a20bbea61f1d14578854e903404a3826a763470e6e136
|
| 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.2-py3-none-any.whl
| Download URL | switchlane-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dea42531eb91ea358be0f2c6091ef45a2294287a5de548044885d93707eee6b1
|
|
BLAKE2b-256 checksum How to use checksums |
90c6784665cc1868b9179e0ec86d228210ede6095b7847113404ffb52552a7aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.2
|