Skip to content

processJsonConfig

processJsonConfig(llmConfig): Promise<BaseChatModel<BaseChatModelCallOptions, AIMessageChunk<MessageStructure<MessageToolSet>>>>

Defined in: _worktrees/docs-release/gaunt-sloth/packages/core/src/providers/openrouter.ts:60

Build a native ChatOpenRouter (@langchain/openrouter). It is NOT a ChatOpenAI subclass: it talks to the OpenRouter REST API through the global fetch with no SDK client in between, and _llmType() reports openrouter.

OpenRouter’s own options are therefore native TOP-LEVEL fields of the llm block, forwarded by the ...restConfig spread below: provider (routing preferences), models (the fallback list), route, plugins, transforms, trace, minP, topA, repetitionPenalty, seed, logitBias, topLogprobs, sessionId. Write them beside model, not under configuration.

Migration note — the OpenAI-client knobs a configuration block used to carry are gone, because there is no client to give them to. configuration.baseURL still works (mapped to the native baseURL), and the two attribution headers are still honoured as a fallback for siteUrl/siteName. What has no injection point at all is transport: fetch, fetchOptions, timeout, maxRetries, defaultQuery, dangerouslyAllowBrowser, and any other defaultHeaders entry. That is an upstream surface gap, not something this module can restore — per-provider transport would need a fetch option added to @langchain/openrouter.

The replacement is PROCESS-WIDE rather than per-provider, and it is verified working: run node with --use-env-proxy (or set NODE_USE_ENV_PROXY=1) together with HTTP_PROXY/HTTPS_PROXY, and the global fetch this model calls routes through the proxy — measured end to end against a local proxy, with a no-proxy control that stayed direct.

ChatOpenRouterParams & BaseLanguageModelParams & object & Record<string, unknown>

Promise<BaseChatModel<BaseChatModelCallOptions, AIMessageChunk<MessageStructure<MessageToolSet>>>>