Skip to content
TypeSafe AITypeSafe console
IntroductionAsync client

CLIENTS

Async client

Configure asynchronous System One requests, discover available models, and manage an AsyncTypeSafeClient instance.

typesafe_sdk.AsyncTypeSafeClient

AsyncTypeSafeClient(
    *,
    api_key: str | None = None,
    model: str | None = None,
    retry: RetryPolicy | None = None,
    timeout: float
        | httpx2.Timeout
        | None = None,
    headers: Mapping[str, str] | None = None,
    transport: httpx2.AsyncBaseTransport
        | None = None,
    http_client: httpx2.AsyncClient
        | None = None,
    base_url: str | None = None,
)

Asynchronous client for System One requests and model discovery. Constructor options take precedence over the corresponding environment variables. This recipe preserves the public member names; it does not instantiate a client.

Parameters

NameType / defaultBehavior
api_keystr | None = NoneUses TYPESAFE_API_KEY when omitted. A missing key is an error.
modelstr | None = NoneUses TYPESAFE_DEFAULT_MODEL when omitted; individual requests can select a model.
retryRetryPolicy | None = NoneControls retry behavior. A policy with max_retries=0 disables retries.
timeoutfloat | Timeout | None = NoneInherits a supplied HTTP client timeout, otherwise the SDK default applies.
headersMapping[str, str] | NoneAdditional headers for requests.
transportAsyncBaseTransport | NoneA custom asynchronous transport; mutually exclusive with http_client.
http_clientAsyncClient | NoneA supplied asynchronous client, closed when the SDK client closes.
base_urlstr | None = NoneUses TYPESAFE_BASE_URL when omitted.
Constructor failures

The public contract reports TypeSafeError for a missing key or invalid timeout, and ValueError when both a transport and HTTP client are supplied.

Members

models

Cached AsyncModels resource. Use its list method to discover models.

system_one

await client.system_one(
    state,
    questions,
    model=None,
    retry=None,
    timeout=None,
    extra_headers=None,
    extra_body=None,
    response_model=None,
)

Ready to copy

Returns a SystemOneResponse, or the response type requested through response_model. Required state and questions define the decision input.

aclose

Closes the asynchronous client and its managed HTTP resources. Await cleanup when the application is finished with the client.

Was this page helpful?Choose a local response. Nothing is sent.
Type a page name. Results stay inside this reference.
Enlarged captured poster of the public TypeSafe Smart Home Demo
Still image from the public Loom embed. Open the poster link on the page to watch the original video.