typesafe_sdk.TypeSafeClient
Create an HTTP client for TypeSafe AI API. Explicit options take precedence over environment variables; empty or whitespace-only environment values are ignored. Parameters:-
api_key(str | None, default:None) – Required API key; may be set via theTYPESAFE_API_KEYenvironment variable. Leading and trailing whitespace is stripped. Empty keys, internal whitespace, control characters, and non-ASCII characters are rejected. -
model(str | None, default:None) – Model name; may be set via theTYPESAFE_DEFAULT_MODELenvironment variable. -
retry(RetryPolicy | None, default:None) – ARetryPolicycontrolling retry behavior; seeRetryPolicyfor the available options and their defaults. PassRetryPolicy(max_retries=0)to disable retries. -
timeout(float | httpx2.Timeout | None, default:None) – Timeout for HTTP operations. Inheritshttp_client.timeoutwhen supplied, otherwise the SDK default. -
headers(Mapping[str, str] | None, default:None) – Additional request headers to set. -
transport(httpx2.BaseTransport | None, default:None) – Optional custom HTTP transport, closed when this SDK client closes. -
http_client(httpx2.Client | None, default:None) – Optionalhttpx2.Client; mutually exclusive withtransport. Closed when this SDK client closes. -
base_url(str | None, default:None) – API root; may be set via theTYPESAFE_BASE_URLenvironment variable. -
compression(Literal[‘zstd’, False] | None, default:None) – Request body compression:"zstd", orFalseto send bodies uncompressed. Defaults to zstd when available.
-
TypeSafeError– The API key is missing or invalid, the timeout is invalid, or zstd compression is unavailable. -
ValueError– Bothtransportandhttp_clientare supplied.
models
cached property
An accessor for the Models API resource.
Examples:
attach_assets
Attach assets to calls made within awith block, for referencing them inside strings.
Until the block exits, calls on this client send each attached asset whose reference, str(asset), appears in the request.
Parameters:
Raises:
-
TypeSafeError– An attached value is not an asset.
system_one
- Implementation
- Overload 1
- Overload 2
-
state(Content) – Text, an asset, a JSON object, or an array to evaluate. See state for details. -
questions(Mapping[str, Question]) – Nonempty mapping of names to question objects or raw dictionaries. -
model(str | None, default:None) – Model override;Noneinherits the client default. -
assets(Mapping[str, Asset] | None, default:None) – Assets keyed by the reference used for them instateor questions; see Attaching media assets. -
retry(RetryPolicy | None, default:None) – An optional retry policy to override the client-level value for this call only. -
timeout(float | httpx2.Timeout | None, default:None) – An optional timeout for http operations to override the client-level value for this call only, in seconds. -
extra_headers(Mapping[str, str] | None, default:None) – Additional request headers to set. -
extra_body(Mapping[str, JSONValue | None] | None, default:None) – Additional top-level request-body fields, shallow-merged over the body afterstate,model,questions, andassetsare set. Merging is last-write-wins: a key that collides with those fields overrides it, and object values are replaced rather than deep-merged. -
response_model(type[ResponseT] | None, default:None) – Optional PydanticBaseModeltype describing the JSON response body, including any nested answer models.
-
SystemOneResponse | ResponseT– An instance ofresponse_model, orSystemOneResponsewith answers keyed by question -
SystemOneResponse | ResponseT– name and model and token usage details when no custom model is supplied.
-
TypeSafeError– The request is invalid before it’s sent, such as empty questions or an unreadable asset. -
TypeSafeAPIError– The server returns an unsuccessful HTTP response after any retries. -
TypeSafeAPIConnectionError– The request cannot connect or times out after any retries. -
TypeSafeAPIResponseValidationError– The response body does not match the response model.
close
Models resource
Reached throughTypeSafeClient.models.
typesafe_sdk.Models
Access to the models available to the account, reached throughTypeSafeClient.models.
list
List the models available to the account. Parameters:-
retry(RetryPolicy | None, default:None) – An optional retry policy to override the client-level value for this call only. -
timeout(float | httpx2.Timeout | None, default:None) – Per-operation timeout override;Noneinherits the client setting. -
extra_headers(Mapping[str, str] | None, default:None) – Overrides for additional request headers; authentication, SDK identification, andAcceptremain protected.
-
ListModelsResponse– AListModelsResponsewhosemodelsholds each model’s name, description, -
ListModelsResponse– and release date.
-
TypeSafeAPIError– The server returns an unsuccessful HTTP response after any retries. -
TypeSafeAPIConnectionError– The request cannot connect or times out after any retries.

