Registry / llm-agents / llama-index-llms-langchain

llama-index-llms-langchain

JSON →
library0.8.0pypypiunverified

The `llama-index-llms-langchain` library provides a seamless integration layer, allowing users to leverage LangChain's extensive collection of Large Language Models (LLMs) within the LlamaIndex framework. It acts as a bridge, enabling LangChain LLM instances to conform to LlamaIndex's LLM interface. The current version is `0.8.0`, and it receives regular updates aligned with LlamaIndex core releases.

pip install llama-index-llms-langchain llama-index-core
INSTALL
IMPORT
SIG · LLAMA-INDEX-LLMS-L
L
llama-index-llms-langchain
llm-agentspythonv0.8.0
Install
22.5s avg
Import
6631ms
Disk
306MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.8.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.940 runs
installs and imports cleanly · install 0.0s · import 5.496s · 289.7MB
glibc
py 3.103.940 runs
installs and imports cleanly · install 22.5s · import 5.113s · 293MB
306MB installed
● package 306MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

LangChainLLM
from llama_index.llms.langchain import LangChainLLM
from llama_index.integrations.llms.langchain import LangChainLLM
Import path changed with LlamaIndex v0.10+ package restructuring. Older versions used the `integrations` namespace.

This quickstart demonstrates how to instantiate a LangChain LLM (using `ChatOpenAI` as an example), wrap it using `LangChainLLM` from `llama-index-llms-langchain`, and then configure it as the default LLM within LlamaIndex's `Settings`. It shows both completion and chat interactions.

import os from langchain_openai import ChatOpenAI from llama_index.llms.langchain import LangChainLLM from llama_index.core import Settings # 1. Initialize a LangChain LLM instance # Make sure to install 'langchain-openai' (pip install langchain-openai) # and set your OPENAI_API_KEY environment variable. # Using os.environ.get for safe execution in environments without the key. lc_llm = ChatOpenAI(temperature=0.0, model="gpt-3.5-turbo", api_key=os.environ.get("OPENAI_API_KEY", "test_key")) # 2. Wrap the LangChain LLM with LlamaIndex's LangChainLLM wrapper llm = LangChainLLM(llm=lc_llm) # 3. Use the wrapped LLM with LlamaIndex # You can either set it globally or pass it directly to components. Settings.llm = llm # Example: Generate a completion response = Settings.llm.complete("Tell me a short story about a magical cat.") print(response.text) # Example: Generate a chat response from llama_index.core.llms import ChatMessage, MessageRole chat_response = Settings.llm.chat([ ChatMessage(role=MessageRole.USER, content="What is the capital of France?") ]) print(chat_response.message.content)
Debug
Known issues
breakingLlamaIndex v0.10+ introduced a significant package restructuring. Integration packages like `llama-index-llms-langchain` moved from the `llama_index.integrations` namespace to dedicated namespaces like `llama_index.llms` or `llama_index.embeddings`.
fix
Update import statements. For `LangChainLLM`, change `from llama_index.integrations.llms.langchain import LangChainLLM` to `from llama_index.llms.langchain import LangChainLLM`.
affects: LlamaIndex < 0.10
gotchaThis package (`llama-index-llms-langchain`) only provides the wrapper. You still need to install the specific LangChain provider packages (e.g., `langchain-openai`, `langchain-anthropic`, `langchain-google-genai`) for the LLMs you intend to use.
fix
After installing `llama-index-llms-langchain`, run `pip install langchain-<provider>` for your chosen LLM provider (e.g., `pip install langchain-openai`).
affects: All versions
gotchaEnsure compatible versions of `llama-index-core` and `langchain` (and its sub-packages like `langchain-core`, `langchain-openai`). Version mismatches can lead to `ImportError` or `AttributeError`.
fix
Refer to the `pyproject.toml` or `setup.py` of `llama-index-llms-langchain` on GitHub for exact dependency version constraints, or update all related packages: `pip install -U llama-index-llms-langchain llama-index-core langchain langchain-core langchain-openai`.
affects: All versions
Upgrade
Version history
0.8.0latest on PyPI · released Mar 12, 2026
Audit
Dependencies
llama-index-corerequiredRequired for core LlamaIndex functionalities.
langchain-corerequiredCore LangChain dependencies, specifically >=0.2.0, <0.3.0.
langchainrequiredCore LangChain library, specifically >=0.1.0, <0.2.0.
langchain-openaioptionalExample LangChain LLM provider. Users must install their desired LangChain LLM provider (e.g., langchain-anthropic, langchain-community).
Agent activity
10 hits · last 30 days
node
8
Amazon
1
OpenAI (training)
1
Resources
llama-index-llms-langchain — pip install llama-index-llms-langchain · libregistry