Skip to main content

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)

License

MIT © Ekrem Aksoy. The Switchlane server is licensed separately under AGPL-3.0-only.

Release files for switchlane 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for switchlane 0.1.3
File Size Uploaded
switchlane-0.1.3.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for switchlane 0.1.3
File Interpreter ABI Platform
switchlane-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 11.4 kB

Release files / switchlane-0.1.3.tar.gz

Download URL switchlane-0.1.3.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1a8033d978de0224b659a6de004fe3c03c9bdb5478f997104a87ab763fc3c4d1
BLAKE2b-256 checksum
How to use checksums
e19eb2168f5918c0379268d8f580e396deab561ee6ffeabfd67e2fd104328686
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.3-py3-none-any.whl

Download URL switchlane-0.1.3-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48830e91fc3d3285f2e1774f82df2a4b1b8bf5cae025db5620d42e5d7006de50
BLAKE2b-256 checksum
How to use checksums
c7122277fa9bf027eaa7446c1ef88ac674c7aee1cb7ec399cd15048b8593e2e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page