Python SDK

Stable

Production routing and agent runtime for Python services, notebooks, and serverless.

Install

pip install skyaiapp
# or
poetry add skyaiapp
export SKYAIAPP_API_KEY="sk_live_..."

Quickstart

import os
from skyaiapp import SkyAI

sky = SkyAI(
    api_key=os.environ["SKYAIAPP_API_KEY"],
    project_id="proj_123",
)

res = sky.route(
    goal="cost",
    strategy="balanced",
    messages=[{"role": "user", "content": "Summarize this document..."}],
)

print(res.output)
print(res.trace_id)

Async + streaming

import asyncio
from skyaiapp import AsyncSkyAI

sky = AsyncSkyAI(api_key="...", project_id="proj_123")

async def main():
    stream = await sky.route_stream(
        goal="quality",
        strategy="quality-first",
        messages=[{"role": "user", "content": "Draft a launch email."}],
    )
    async for chunk in stream:
        print(chunk.delta or "", end="")

asyncio.run(main())

Policies and budgets

res = sky.route(
    policy_id="pol_2025_12_01",
    messages=messages,
    metadata={
        "tenant_id": "acme",
        "user_tier": "pro",
        "locale": "en-US",
    },
)

Metadata is attached to traces and can be referenced in routing rules.

Agent runtime

result = sky.agent.run(
    name="support-triage",
    input={"ticket_id": "TCK-9912"},
    tools={
        "lookup_ticket": lookup_ticket,
        "summarize_history": summarize_history,
    },
)

print(result.output)

Error handling

from skyaiapp import SkyAIError

try:
    sky.route(messages=messages)
except SkyAIError as e:
    if e.code == "RATE_LIMITED":
        time.sleep(1.2)
        # retry
    raise
Python SDK — SkyAIApp