OpenRouterConfig.ts
OpenRouterConfig.ts overview
Section titled “OpenRouterConfig.ts overview”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.
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 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.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”OpenRouterConfig (class)
Section titled “OpenRouterConfig (class)”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
withClientTransformfor scoping an HTTP client transformation
Signature
declare class OpenRouterConfigSince v4.0.0
OpenRouterConfig (namespace)
Section titled “OpenRouterConfig (namespace)”Types associated with the OpenRouterConfig context service.
Since v4.0.0
Service (interface)
Section titled “Service (interface)”Configuration values read by OpenRouter provider operations when resolving the generated HTTP client.
Signature
export interface Service { readonly transformClient?: ((client: HttpClient) => HttpClient) | undefined}Since v4.0.0