TypeSafe Python SDK
TypeSafe Python SDK를 설치하고 비동기 또는 동기 API 호출을 시작합니다.
GitHub에서 Python SDK 소스를 살펴보십시오.
TypeSafe API를 위한 비동기 및 동기 Python 클라이언트입니다. TypeSafe 사용법은 여기에서 알아보십시오.
빠른 시작
-
SDK를 설치합니다:
uv add typesafe-sdkpip install typesafe-sdkHTTP/2 지원을 사용하려면
http2추가 기능(typesafe-sdk[http2])을 넣으십시오. -
환경에
TYPESAFE_API_KEY를 설정합니다(여기에서 생성). -
System One API를 호출합니다:
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)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)
다음 단계
사용 가이드에서 타입이 지정된 응답, 모델 선택, 재시도, HTTP/2, 오류 처리 같은 패턴을 더 알아보십시오.