Skip to content

OpenAiConfig

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.

3 exports Added in v4.0.0 Source

Configuration

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<A, E, R>) => Effect<A, E, R>;
  <A, E, R>(self: Effect<A, E, R>, transform: (client: HttpClient) => HttpClient): Effect<A, E, R>;
};

Other

OpenAiConfig

Added in v4.0.0 Source

Types used by the OpenAiConfig context service.

Services

OpenAiConfig

Added in v4.0.0 Source

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

Signature

declare class OpenAiConfig extends Shape<"@effect/ai-openai/OpenAiConfig", Service, this> {
  constructor(_: never);
  static readonly getOrUndefined: Effect<Service | undefined>;
}