CloudflareClient unstable
HTTP client for Cloudflare Clef decisions through Workers AI REST.
Constructors
Layers
Provides a Cloudflare client from explicit options.
Signature
declare function layer(options: Options): Layer<CloudflareClient, never, HttpClient>layerConfig
unstable Since v4.0.0 Source
Provides a client from configuration. It reads CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN, and the optional
CLOUDFLARE_AI_GATEWAY_ID by default.
Signature
declare function layerConfig(options?: { readonly accountId?: Config<string>; readonly apiKey?: Config<Redacted<string>>; readonly apiUrl?: Config<string>; readonly gatewayId?: Config<string>; readonly transformClient?: (client: HttpClient) => HttpClient;}): Layer<CloudflareClient, ConfigError, HttpClient>Options
Account, authentication, AI Gateway, API base URL, and HTTP customization options.
Signature
interface Options { readonly accountId: string; readonly apiKey: Redacted<string>; readonly apiUrl?: string; readonly gatewayId?: string; readonly transformClient?: (client: HttpClient) => HttpClient;}Services
CloudflareClient
unstable Since v4.0.0 Source
Cloudflare Workers AI client service.
Signature
declare class CloudflareClient extends Shape<"@effect/ai-cloudflare/CloudflareClient", Service, this> { constructor(_: never);}Low-level Cloudflare decision operations.
Signature
interface Service { readonly client: HttpClient; readonly createDecisions: (request: { readonly images?: readonly Array<string | { readonly base64: string; readonly content_type: string & {} | "image/png" | "image/jpeg" | "image/webp"; }>; readonly model: "clef" | "clef-flash" | string & {}; readonly questions: { [key: string]: { readonly criteria: { [key: string]: string | { [key: string]: Json; } | readonly Array<Json> | null; }; readonly instructions: string | { [key: string]: Json; } | readonly Array<Json>; readonly type: "choice"; } | { readonly criteria: readonly Array<Json>; readonly instructions: string | { [key: string]: Json; } | readonly Array<Json>; readonly type: "score"; } | { readonly criteria?: { readonly false: Json; readonly true: Json; }; readonly instructions: string | { [key: string]: Json; } | readonly Array<Json>; 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]: Json; }; 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>;}