Skip to content
Effect Days 2026 Get your ticket

TypeSafeClient

HTTP client for TypeSafe System One and model discovery.

6 exports Added in v4.0.0 Source

Constructors

make

Added in v4.0.0 Source

Builds a client without automatic retries. Scoped transforms run after the constructor transform.

Signature

declare const make: (...args: [options: Options]) => Effect<Service, never, HttpClient>

Layers

layer

Added in v4.0.0 Source

Provides a client from explicit options.

Signature

declare function layer(options: Options): Layer<TypeSafeClient, never, HttpClient>

layerConfig

Added in v4.0.0 Source

Provides a client from configuration, defaulting to TYPESAFE_API_KEY.

Signature

declare function layerConfig(options?: {
readonly apiKey?: Config<Redacted<string> | undefined>;
readonly apiUrl?: Config<string>;
readonly transformClient?: (client: HttpClient) => HttpClient;
}): Layer<TypeSafeClient, ConfigError, HttpClient>

Options

Options interface

Added in v4.0.0 Source

Authentication, endpoint and HTTP customization options.

Signature

interface Options {
readonly apiKey?: Redacted<string>;
readonly apiUrl?: string;
readonly transformClient?: (client: HttpClient) => HttpClient;
}

Services

Service interface

Added in v4.0.0 Source

Low-level TypeSafe operations.

Signature

interface Service {
readonly client: HttpClient;
readonly listModels: () => Effect<{
readonly models: readonly Array<{
readonly description?: string;
readonly name: string;
readonly release_date?: string;
}>;
}, AiError>;
readonly systemOne: (request: {
readonly model: string;
readonly questions: {
[key: string]: {
readonly criteria: {
[key: string]: string;
};
readonly instructions: string;
readonly type: "choice";
} | {
readonly criteria: readonly Array<string>;
readonly instructions: string;
readonly type: "score";
} | {
readonly criteria?: {
readonly false: string;
readonly true: string;
};
readonly instructions: string;
readonly type: "noul";
};
};
readonly state: Json;
}) => Effect<{
readonly answers: {
[key: string]: {
readonly choice: string;
readonly confidence: number;
readonly probabilities: {
[key: string]: number;
};
readonly type: "choice";
} | {
readonly confidence: number;
readonly legend?: {
[key: string]: string;
};
readonly probabilities: {
[key: string]: number;
};
readonly score: number;
readonly type: "score";
} | {
readonly noul: number;
readonly type: "noul";
};
};
readonly model: string;
readonly usage?: {
readonly input_tokens?: number;
readonly output_tokens?: number;
};
}, AiError>;
}

TypeSafe client service.

Signature

declare class TypeSafeClient extends Shape<"@effect/ai-typesafe/TypeSafeClient", Service, this> {
constructor(_: never);
}