TypeSafe Python SDK
TypeSafe Python SDK
Install the TypeSafe Python SDK and get started with asynchronous or synchronous API calls.
Browse the Python SDK source on GitHub.
Asynchronous and synchronous Python clients for the TypeSafe API. Learn how to use TypeSafe here.
Quickstart
-
Install the SDK:
uv add typesafe-sdkpip install typesafe-sdkAdd the
http2extra (typesafe-sdk[http2]) to enable HTTP/2 support. -
Set
TYPESAFE_API_KEYin your environment (create it here) -
Call the System One API:
With AsyncTypeSafeClient:
from typesafe_sdk import AsyncTypeSafeClient, Choice, Noul, Score async def main() -> None: async with AsyncTypeSafeClient() as client: response = await client.system_one( state={"document": "I was charged twice. Please fix this ASAP."}, questions={ "billing": Noul(instructions="Is this ticket about billing?"), "tone": Choice( instructions="What is the customer's tone?", criteria={"calm": None, "frustrated": None, "angry": None}, ), "urgency": Score( instructions="How urgent is this ticket?", criteria=["can wait", "this week", "today"], ), }, ) print(response.nouls["billing"].noul) print(response.choices["tone"].choice) print(response.scores["urgency"].score)With TypeSafeClient:
from typesafe_sdk import Choice, Noul, Score, TypeSafeClient with TypeSafeClient() as client: response = client.system_one( state={"document": "I was charged twice. Please fix this ASAP."}, questions={ "billing": Noul(instructions="Is this ticket about billing?"), "tone": Choice( instructions="What is the customer's tone?", criteria={"calm": None, "frustrated": None, "angry": None}, ), "urgency": Score( instructions="How urgent is this ticket?", criteria=["can wait", "this week", "today"], ), }, ) print(response.nouls["billing"].noul) print(response.choices["tone"].choice) print(response.scores["urgency"].score)
What’s next
Visit the Usage guide to learn more about patterns such as typed responses, model selection, retries, HTTP/2, or error handling.