Skip to main content

Smart AI model routing with real-time status awareness. Pre-flight checks, auto-fallback, budget constraints.

Project description

aistatus

Smart AI model routing with real-time status awareness.

aistatus checks provider/model availability through aistatus.cc, then calls your installed provider SDK directly. Your prompts and API keys stay on your side.

Install

pip install aistatus
pip install aistatus[anthropic]
pip install aistatus[openai]
pip install aistatus[google]
pip install aistatus[all]

Quickstart

Set at least one provider API key, then route by model name:

from aistatus import route

resp = route(
    "Summarize the latest deployment status.",
    model="claude-sonnet-4-6",
)

print(resp.content)
print(resp.model_used)
print(resp.provider_used)
print(resp.was_fallback)

If the primary provider is unavailable, aistatus tries other compatible providers that are available in your environment.

Tier Routing

Tier routing is supported, but tiers must be configured explicitly:

from aistatus import Router

router = Router(check_timeout=2.0)
router.add_tier("fast", [
    "claude-haiku-4-5",
    "gpt-4o-mini",
    "gemini-2.0-flash",
])
router.add_tier("standard", [
    "claude-sonnet-4-6",
    "gpt-4o",
    "gemini-2.5-pro",
])

resp = router.route(
    "Explain quantum computing in one sentence.",
    tier="fast",
)

Async

from aistatus import aroute

resp = await aroute(
    [{"role": "user", "content": "Hello"}],
    model="gpt-4o-mini",
)

Status API

from aistatus import StatusAPI

api = StatusAPI()

check = api.check_provider("anthropic")
print(check.status)
print(check.is_available)

for provider in api.providers():
    print(provider.name, provider.status.value)

for model in api.search_models("sonnet"):
    print(model.id, model.prompt_price, model.completion_price)

Response Object

Every route() call returns a RouteResponse:

@dataclass
class RouteResponse:
    content: str
    model_used: str
    provider_used: str
    was_fallback: bool
    fallback_reason: str | None = None
    input_tokens: int = 0
    output_tokens: int = 0
    cost_usd: float = 0.0
    raw: Any = None

Errors

from aistatus import AllProvidersDown, ProviderNotInstalled, route

try:
    resp = route("Hello", model="claude-sonnet-4-6")
except AllProvidersDown as e:
    print(e.tried)
except ProviderNotInstalled as e:
    print(f"Install support for: {e.provider}")

Environment Variables

The SDK auto-discovers providers from standard environment variables:

ANTHROPIC_API_KEY=...
OPENAI_API_KEY=...
GEMINI_API_KEY=...
OPENROUTER_API_KEY=...
DEEPSEEK_API_KEY=...
MISTRAL_API_KEY=...
XAI_API_KEY=...
GROQ_API_KEY=...
TOGETHER_API_KEY=...
MOONSHOT_API_KEY=...
DASHSCOPE_API_KEY=...

License

MIT. See LICENSE.

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

aistatus-0.0.1.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

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

aistatus-0.0.1-py3-none-any.whl (29.9 kB view details)

Uploaded Python 3

File details

Details for the file aistatus-0.0.1.tar.gz.

File metadata

  • Download URL: aistatus-0.0.1.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aistatus-0.0.1.tar.gz
Algorithm Hash digest
SHA256 80b609fdf57730576307fd71ec3e1d422ad1cb0ab2d65cf68464385fdfde8b4f
MD5 f52fae492ff59a1933f706fff9e74683
BLAKE2b-256 2a6b03ed842815dd60f7e73c5ec15130d86d9e431e4129eed247f51606fa90a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for aistatus-0.0.1.tar.gz:

Publisher: pypi-publish.yml on fangxm233/aistatus-python

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

File details

Details for the file aistatus-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: aistatus-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aistatus-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b2f150533754a9869a04f7bb617590996fb630e0ee34884457f08787ca50c988
MD5 adb6d843f44886f6adc2387f08d935fb
BLAKE2b-256 cf1aa59fbadb336793ee593962fe410b2aa8b1defebc3761de4e0cd5f6298909

See more details on using hashes here.

Provenance

The following attestation bundles were made for aistatus-0.0.1-py3-none-any.whl:

Publisher: pypi-publish.yml on fangxm233/aistatus-python

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