Constructor parameters for ChatOpenRouter.
interface ChatOpenRouterInputOpenRouter API key. Falls back to OPENROUTER_API_KEY env var.
Base URL for the API. Defaults to "https://openrouter.ai/api/v1".
Whether to disable streaming.
If streaming is bypassed, then stream() will defer to
invoke().
Additive penalty based on how often a token has appeared so far (−2 to 2).
Token-level biases to apply during sampling.
The maximum number of concurrent calls that can be made.
Defaults to Infinity, which means no limit.
The maximum number of retries that can be made for a single call, with an exponential backoff between each attempt. Defaults to 6.
Maximum number of tokens to generate.
Minimum probability threshold for token sampling.
Model identifier, e.g. "anthropic/claude-4-sonnet".
OpenRouter-specific list of models for routing.
Custom handler to handle failed attempts. Takes the originally thrown error object as input, and should itself throw an error if the input error is not retryable.
Version of AIMessage output format to store in message content.
AIMessage.contentBlocks will lazily parse the contents of content into a
standard format. This flag can be used to additionally store the standard format
as the message content, e.g., for serialization purposes.
.contentBlocks).contentBlocks)You can also set LC_OUTPUT_VERSION as an environment variable to "v1" to
enable this by default.
OpenRouter plugins to enable (e.g. web search).
Additive penalty based on whether a token has appeared at all (−2 to 2).
OpenRouter-specific provider preferences and ordering.
Multiplicative penalty applied to repeated token logits (0 to 2).
OpenRouter-specific routing strategy.
Random seed for deterministic generation.
Application title for OpenRouter attribution. Maps to X-Title header.
Defaults to "langchain".
See https://openrouter.ai/docs/app-attribution for details.
Application URL for OpenRouter attribution. Maps to HTTP-Referer header.
Defaults to "https://docs.langchain.com/oss".
See https://openrouter.ai/docs/app-attribution for details.
Stop sequences that halt generation.
Whether to include usage in streaming chunks. Defaults to true.
Sampling temperature (0–2).
Top-A sampling threshold.
Top-K sampling: only consider the K most likely tokens.
Number of most-likely log-probabilities to return per token.
Nucleus sampling cutoff probability.
OpenRouter-specific transformations to apply to the request.
Stable identifier for end-users, used for abuse detection.
Additive penalty based on how often a token has appeared so far (−2 to 2).
Token-level biases to apply during sampling.
Maximum number of tokens to generate.
Minimum probability threshold for token sampling.
Additive penalty based on whether a token has appeared at all (−2 to 2).
Multiplicative penalty applied to repeated token logits (0 to 2).
Top-A sampling threshold.
Top-K sampling: only consider the K most likely tokens.
Number of most-likely log-probabilities to return per token.
Nucleus sampling cutoff probability.
OpenRouter-specific transformations to apply to the request.