mcp-use TypeScript API
    Preparing search index...

    Function createLLMFromString

    • Dynamically imports and instantiates a LangChain chat model.

      Parameters

      • llmString: string

        LLM specification in format "provider/model" (e.g., "openai/gpt-4")

      • Optionalconfig: LLMConfig

        Optional configuration for the LLM (apiKey, temperature, etc.)

      Returns Promise<any>

      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 });
      
      const llm = await createLLMFromString('anthropic/claude-sonnet-4-6');