Switchyard lets LLM applications route traffic across models and providers while preserving native OpenAI and Anthropic API compatibility - enabling flexible model selection, benchmarking, and cost/performance optimization.
Rust
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Native Rust Switchyard server host."""
from os import PathLike
from typing import TYPE_CHECKING, Any, final
from switchyard_rust._native import load_native
if TYPE_CHECKING:
from typing_extensions import Self
class ServerConfigError(RuntimeError):
"""Raised when a native server deployment configuration is invalid."""
@final
class Server:
"""Running loopback instance of the native Switchyard server."""
def __init__(self, config: str | PathLike[str], port: int = 0) -> None: ...
@property
def port(self) -> int: ...
@property
def base_url(self) -> str: ...
def caller_auth_kind(self, model: str) -> str | None: ...
def close(self, timeout_secs: float = 2.0) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self,
exception_type: type[BaseException] | None,
exception: BaseException | None,
traceback: object | None,
) -> bool: ...
def __getattr__(name: str) -> object:
if name in {"Server", "ServerConfigError"}:
native: Any = load_native()
return getattr(native.server, name)
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
__all__ = ["Server", "ServerConfigError"]