OpenAiConfig.ts
OpenAiConfig.ts overview
Section titled “OpenAiConfig.ts overview”The OpenAiConfig module lets a workflow temporarily customize the HTTP
client used by @effect/ai-openai request helpers. OpenAI client, language
model, and embedding code read this scoped transform when they execute
provider calls.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”configuration
Section titled “configuration”withClientTransform
Section titled “withClientTransform”Provides a scoped transform for the OpenAI HTTP client used by provider operations.
When to use
Use when you need temporary OpenAI HTTP client customization for a single effect or workflow without rebuilding the client layer.
Details
Supports both data-first and data-last forms. The transform is stored in the
scoped OpenAiConfig service and read by OpenAI provider operations while
running the supplied effect.
Gotchas
If a transform is already present in the scoped config, this helper replaces it. Compose transforms manually when both should apply.
Signature
declare const withClientTransform: { (transform: (client: HttpClient) => HttpClient): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> <A, E, R>(self: Effect.Effect<A, E, R>, transform: (client: HttpClient) => HttpClient): Effect.Effect<A, E, R>}Since v4.0.0
services
Section titled “services”OpenAiConfig (class)
Section titled “OpenAiConfig (class)”Context service for scoped OpenAI configuration used by provider operations.
When to use
Use to provide scoped OpenAI client configuration, such as an HTTP client transform, to OpenAI provider operations without passing it through each call.
See
withClientTransformfor scoping an HTTP client transformation
Signature
declare class OpenAiConfigSince v4.0.0
OpenAiConfig (namespace)
Section titled “OpenAiConfig (namespace)”Types used by the OpenAiConfig context service.
Since v4.0.0
Service (interface)
Section titled “Service (interface)”Configuration values read by OpenAI provider operations when executing requests.
Signature
export interface Service { readonly transformClient?: ((client: HttpClient) => HttpClient) | undefined}Since v4.0.0