Class: TypeSafeClient
Class: TypeSafeClient
Client for the TypeSafe AI API.
Constructors
Constructor
new TypeSafeClient(config?): TypeSafeClient;
Create a client for the TypeSafe AI API.
Explicit options take precedence over environment variables, then SDK defaults. Empty or whitespace-only environment values are ignored.
Parameters
config?
TypeSafeClientConfig = {}
Returns
TypeSafeClient
Throws
The API key is missing, configuration is invalid, or the runtime is unsupported.
Properties
baseURL
readonly baseURL: string;
API root with trailing slashes removed.
defaultHeaders
readonly defaultHeaders: Readonly<Record<string, string>>;
Additional headers sent with each request.
defaultModel
readonly defaultModel: string;
Model used when a request omits model.
fetch
readonly fetch: Fetch;
HTTP fetch implementation.
logger
readonly logger: Logger;
The configured logger, filtered to logLevel.
logLevel
readonly logLevel: LogLevel;
Configured log verbosity.
models
readonly models: Models;
The models available to the account.
retry
readonly retry: RetryPolicy;
Retry settings with constructor overrides applied.
timeout
readonly timeout: number;
Timeout per attempt in milliseconds.
Methods
systemOne()
systemOne<Q>(request, options?): APIPromise<SystemOneResult<Q>>;
Answer named questions about text or structured state.
Type Parameters
Q
Q extends Questions
Parameters
request
State, questions, and an optional model override.
options?
RequestOptions = {}
Per-call timeout, retry, headers, and cancellation settings.
Returns
APIPromise<SystemOneResult<Q>>
Answers typed by question name and criteria, with model and token usage.
Throws
Questions are empty, or score criteria are not a list of at least two entries.
Throws
The server returns a non-2xx response after retries.
Throws
The request cannot connect or times out after retries.
Throws
The caller aborts the request.
Example
const { answers } = await client.systemOne({
state: "I was charged twice. Please help.",
questions: { billing: noul("Is this about billing?") },
});
console.log(answers.billing.noul);