Registry / ai-ml / langchain-oci

langchain-oci

JSON →
library0.2.7pypypi✓ verified 80d ago

An integration package connecting Oracle Cloud Infrastructure (OCI) services with LangChain. It provides access to OCI's Generative AI models, OCI Doc AI for document understanding, and OCI OpenSearch as a vector store. Current version 0.2.7, updated regularly with OCI changes.

pip install langchain-oci
INSTALL
IMPORT
SIG · LANGCHAIN-OCI
L
langchain-oci
ai-mlpythonv0.2.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

ChatOCIGenAI
from langchain_oci import ChatOCIGenAI
from langchain_oci.chat_models import ChatOCIModel
OCIGenAIEmbeddings
from langchain_oci import OCIGenAIEmbeddings
OCIModelDeploymentLLM
from langchain_oci import OCIModelDeploymentLLM

Initialize and use an OCI chat model. Requires OCI credentials configured via environment variables or OCI config file.

from langchain_oci.chat_models import ChatOCIModel llm = ChatOCIModel( model_id="cohere.command-r-08-2024", compartment_id=os.environ.get("OCI_COMPARTMENT_ID", ""), auth_type="API_KEY", model_kwargs={"temperature": 0.7, "max_tokens": 100} ) response = llm.invoke("Hello, how are you?") print(response.content)
Debug
Known issues
breakingIn version 0.2.0, the package was restructured: classes moved from top-level to submodules. Any code using direct imports like `from langchain_oci import ChatOCIModel` will break.
fix
Change imports to `from langchain_oci.chat_models import ChatOCIModel`.
affects: >=0.2.0
deprecatedThe `auth_type` parameter 'INSTANCE_PRINCIPAL' is deprecated in favor of 'RESOURCE_PRINCIPAL' for OCI authentication.
fix
Use auth_type='RESOURCE_PRINCIPAL' and set OCI_RESOURCE_PRINCIPAL_VERSION env var.
affects: >=0.1.0
gotchaThe `OCIOpenSearchVectorStore` requires the OpenSearch client and additional dependencies. Install with `pip install langchain-oci[opensearch]`.
fix
Install the optional dependencies: `pip install langchain-oci[opensearch]`.
affects: all
gotchaWhen using OCI GenAI models, the compartment_id is mandatory and must be the OCID of a compartment in the same tenancy as the endpoint. A common mistake is using root compartment or wrong region.
fix
Ensure compartment_id is set correctly and that the OCI region matches the endpoint region.
affects: all
Upgrade
Version history
0.2.7latest on PyPI · released Jun 2, 2026
Audit
Dependencies
langchain-corerequiredCore LangChain abstractions
ocirequiredOracle Cloud Infrastructure Python SDK
langchain-opensearchoptionalFor OpenSearch vector store
Agent activity
17 hits · last 30 days
node
16
Resources
langchain-oci — pip install langchain-oci · libregistry