langchain/libs/partners/openai
2025-07-10 15:17:21 -04:00
..
langchain_openai Merge branch 'master' into v04_standard_outputs 2025-07-10 15:17:21 -04:00
scripts
tests enable code interpreter test for v1 2025-07-10 15:16:24 -04:00
.gitignore
LICENSE
Makefile fix: automatically fix issues with ruff (#31897) 2025-07-07 14:13:10 -04:00
pyproject.toml ruff: more rules across the board & fixes (#31898) 2025-07-07 17:48:01 -04:00
README.md
uv.lock openai: release 0.3.27 (#31769) 2025-06-27 13:44:45 -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 here

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 here

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 here