Skip to content

OpenRouterConfig

The OpenRouterConfig module lets a workflow temporarily customize the HTTP client used by generated OpenRouter request methods. OpenRouterClient reads this scoped transform when generated client operations execute, so callers can add middleware or instrumentation without rebuilding the client layer.

3 exports Added in v4.0.0 Source

Configuration

Provides a scoped transform for the OpenRouter HTTP client used by provider operations.

When to use

Use when you need temporary OpenRouter 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 OpenRouterConfig service and read by generated OpenRouter request 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. Streaming chat completion requests are sent directly by OpenRouterClient.make and do not read this scoped transform.

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

Types associated with the OpenRouterConfig context service.

Services

Context service for scoped OpenRouter provider configuration used by client operations.

When to use

Use as the context service tag when manually providing or reading scoped OpenRouter provider configuration in an Effect context.

See

Signature

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