OpenRouterLanguageModel.ts
OpenRouterLanguageModel.ts overview
Section titled “OpenRouterLanguageModel.ts overview”Exports Grouped by Category
Section titled “Exports Grouped by Category”configuration
Section titled “configuration”withConfigOverride
Section titled “withConfigOverride”Provides config overrides for OpenRouter language model operations.
When to use
Use to apply OpenRouter request configuration to one effect without changing the model’s default configuration.
Details
The overrides are merged with any existing Config service for the duration
of the supplied effect. Fields in overrides take precedence over existing
config, and the helper supports both pipe form and
withConfigOverride(effect, overrides).
See
Configfor available OpenRouter request configuration fields
Signature
declare const withConfigOverride: { (overrides: typeof Config.Service): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Config>> <A, E, R>(self: Effect.Effect<A, E, R>, overrides: typeof Config.Service): Effect.Effect<A, E, Exclude<R, Config>>}Since v4.0.0
constructors
Section titled “constructors”Creates an OpenRouter LanguageModel service from a model identifier and
optional request defaults.
When to use
Use when you need to construct a LanguageModel.Service value backed by
OpenRouterClient inside an Effect.
Details
The returned effect requires OpenRouterClient. Request defaults from the
config option are merged with any Config service in the context, with
context values taking precedence. The service supports both generateText
and streamText.
Gotchas
Provider-defined tools are not supported by this provider integration;
requests that include them fail with an InvalidUserInputError.
See
layerfor providing the service as aLayermodelfor creating a model descriptor forEffect.providewithConfigOverridefor scoping request defaults around operations
Signature
declare const make: (args_0: { readonly model: string readonly config?: Omit<typeof Config.Service, "model"> | undefined}) => Effect.Effect<LanguageModel.Service, never, OpenRouterClient>Since v4.0.0
Creates an OpenRouter model descriptor that can be provided with
Effect.provide.
When to use
Use when you want an OpenRouter language model value that carries provider and model metadata and can be supplied directly to an Effect program.
Details
The returned model requires OpenRouterClient and provides
LanguageModel.LanguageModel.
See
layerfor creating aLanguageModel.LanguageModellayer directlymakefor constructing the language model service effectfullywithConfigOverridefor scoping OpenRouter request overrides
Signature
declare const model: ( model: string, config?: Omit<typeof Config.Service, "model">) => AiModel.Model<"openai", LanguageModel.LanguageModel, OpenRouterClient>Since v4.0.0
layers
Section titled “layers”Creates a layer for the OpenRouter language model.
When to use
Use when composing application layers and you want OpenRouter to satisfy
LanguageModel.LanguageModel while supplying OpenRouterClient from another
layer.
See
makefor constructing the language model service effectfullymodelfor creating a model descriptor forEffect.provide
Signature
declare const layer: (options: { readonly model: string readonly config?: Omit<typeof Config.Service, "model"> | undefined}) => Layer.Layer<LanguageModel.LanguageModel, never, OpenRouterClient>Since v4.0.0
models
Section titled “models”FileAnnotation (type alias)
Section titled “FileAnnotation (type alias)”File annotations emitted on OpenRouter assistant messages and exposed in finish metadata.
Signature
type FileAnnotation = Extract< NonNullable<typeof Generated.AssistantMessage.fields.annotations.Type>[number], { type: "file" }>Since v4.0.0
ReasoningDetails (type alias)
Section titled “ReasoningDetails (type alias)”OpenRouter assistant reasoning detail blocks preserved for multi-turn conversations.
Signature
type ReasoningDetails = Exclude<(typeof Generated.AssistantMessage.Encoded)["reasoning_details"], undefined>Since v4.0.0
services
Section titled “services”Config (class)
Section titled “Config (class)”Context service for OpenRouter language model configuration.
When to use
Use to provide scoped OpenRouter chat completion defaults or per-operation overrides for an OpenRouter language model service.
See
withConfigOverridefor scoping language model request overrides
Signature
declare class ConfigSince v4.0.0