MCPcopy Create free account
hub / github.com/Effect-TS/effect / layerConfig

Function layerConfig

packages/ai/openrouter/src/OpenRouterClient.ts:266–305  ·  view source on GitHub ↗
(options: {
  readonly apiKey?: Config.Config<Redacted.Redacted> | undefined
  readonly apiUrl?: Config.Config<string> | undefined
  /**
   * Optional URL of your site for rankings on `openrouter.ai`.
   */
  readonly referrer?: Config.Config<string> | undefined
  /**
   * Optional title of your site for rankings on `openrouter.ai`.
   */
  readonly title?: Config.Config<string> | undefined
  /**
   * A function to transform the underlying HTTP client before it's used to send
   * API requests.
   *
   * This transformation function receives the configured HTTP client and returns
   * a modified version. It's applied after all standard client configuration
   * (authentication, base URL, headers) but before any requests are made.
   *
   * Use this for:
   * - Adding custom middleware (logging, metrics, caching)
   * - Modifying request/response processing behavior
   * - Adding custom retry logic or error handling
   * - Integrating with monitoring or debugging tools
   * - Applying organization-specific HTTP client policies
   *
   * The transformation is applied once during client initialization and affects
   * all subsequent API requests made through this client instance.
   *
   * Leave absent or set to `undefined` if no custom HTTP client behavior is
   * needed.
   */
  readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
})

Source from the content-addressed store, hash-verified

264 * @category Layers
265 */
266export const layerConfig = (options: {
267 readonly apiKey?: Config.Config<Redacted.Redacted> | undefined
268 readonly apiUrl?: Config.Config<string> | undefined
269 /**
270 * Optional URL of your site for rankings on `openrouter.ai`.
271 */
272 readonly referrer?: Config.Config<string> | undefined
273 /**
274 * Optional title of your site for rankings on `openrouter.ai`.
275 */
276 readonly title?: Config.Config<string> | undefined
277 /**
278 * A function to transform the underlying HTTP client before it's used to send
279 * API requests.
280 *
281 * This transformation function receives the configured HTTP client and returns
282 * a modified version. It's applied after all standard client configuration
283 * (authentication, base URL, headers) but before any requests are made.
284 *
285 * Use this for:
286 * - Adding custom middleware (logging, metrics, caching)
287 * - Modifying request/response processing behavior
288 * - Adding custom retry logic or error handling
289 * - Integrating with monitoring or debugging tools
290 * - Applying organization-specific HTTP client policies
291 *
292 * The transformation is applied once during client initialization and affects
293 * all subsequent API requests made through this client instance.
294 *
295 * Leave absent or set to `undefined` if no custom HTTP client behavior is
296 * needed.
297 */
298 readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined
299}): Layer.Layer<OpenRouterClient, ConfigError, HttpClient.HttpClient> => {
300 const { transformClient, ...configs } = options
301 return Config.all(configs).pipe(
302 Effect.flatMap((configs) => make({ ...configs, transformClient })),
303 Layer.effect(OpenRouterClient)
304 )
305}
306
307/**
308 * @since 1.0.0

Callers

nothing calls this directly

Calls 2

makeFunction · 0.70
pipeMethod · 0.65

Tested by

no test coverage detected