Dynamically imports and instantiates a LangChain chat model.
LLM specification in format "provider/model" (e.g., "openai/gpt-4")
Optional
Optional configuration for the LLM (apiKey, temperature, etc.)
The instantiated LangChain model.
Error if credentials are unavailable, the provider package is not installed, or the model cannot be constructed.
const llm = await createLLMFromString('openai/gpt-4', { temperature: 0.7 }); Copy
const llm = await createLLMFromString('openai/gpt-4', { temperature: 0.7 });
const llm = await createLLMFromString('anthropic/claude-sonnet-4-6'); Copy
const llm = await createLLMFromString('anthropic/claude-sonnet-4-6');
Dynamically imports and instantiates a LangChain chat model.