langchain/libs/partners/openai
Chester Curme 844b8b87d7 Merge branch 'standard_outputs' into cc/openai_v1
# Conflicts:
#	libs/core/langchain_core/language_models/v1/chat_models.py
#	libs/core/langchain_core/messages/utils.py
#	libs/core/langchain_core/messages/v1.py
#	libs/partners/openai/langchain_openai/chat_models/_compat.py
#	libs/partners/openai/langchain_openai/chat_models/base.py
2025-07-28 12:38:32 -04:00
..
langchain_openai Merge branch 'standard_outputs' into cc/openai_v1 2025-07-28 12:38:32 -04:00
scripts
tests add back standard_outputs 2025-07-28 10:47:26 -04:00
.gitignore
LICENSE
Makefile chore: update branch with changes from master (#32277) 2025-07-28 10:39:41 -04:00
pyproject.toml start on openai 2025-07-24 17:12:22 -04:00
README.md chore: update branch with changes from master (#32277) 2025-07-28 10:39:41 -04:00
uv.lock chore: update branch with changes from master (#32277) 2025-07-28 10:39:41 -04:00

langchain-openai

This package contains the LangChain integrations for OpenAI through their openai SDK.

Installation and Setup

  • Install the LangChain partner package
pip install langchain-openai
  • Get an OpenAI api key and set it as an environment variable (OPENAI_API_KEY)

Chat model

See a usage example.

from langchain_openai import ChatOpenAI

If you are using a model hosted on Azure, you should use different wrapper for that:

from langchain_openai import AzureChatOpenAI

For a more detailed walkthrough of the Azure wrapper, see AzureChatOpenAI

Text Embedding Model

See a usage example

from langchain_openai import OpenAIEmbeddings

If you are using a model hosted on Azure, you should use different wrapper for that:

from langchain_openai import AzureOpenAIEmbeddings

For a more detailed walkthrough of the Azure wrapper, see AzureOpenAIEmbeddings

LLM (Legacy)

LLM refers to the legacy text-completion models that preceded chat models. See a usage example.

from langchain_openai import OpenAI

If you are using a model hosted on Azure, you should use different wrapper for that:

from langchain_openai import AzureOpenAI

For a more detailed walkthrough of the Azure wrapper, see Azure OpenAI