Skip to main content

An integration package connecting OpenAI and LangChain

Project description

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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_openai-0.3.12.tar.gz (269.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_openai-0.3.12-py3-none-any.whl (61.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_openai-0.3.12.tar.gz.

File metadata

  • Download URL: langchain_openai-0.3.12.tar.gz
  • Upload date:
  • Size: 269.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for langchain_openai-0.3.12.tar.gz
Algorithm Hash digest
SHA256 c9dbff63551f6bd91913bca9f99a2d057fd95dc58d4778657d67e5baa1737f61
MD5 46396ca002706561482ac5fb674116d4
BLAKE2b-256 320194d861be321df40f104324d3c64115917c7e774bb5d6af45d4af967c863c

See more details on using hashes here.

File details

Details for the file langchain_openai-0.3.12-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_openai-0.3.12-py3-none-any.whl
Algorithm Hash digest
SHA256 0fab64d58ec95e65ffbaf659470cd362e815685e15edbcb171641e90eca4eb86
MD5 c07a49ecc12b59bf19d8254bbe4bb37e
BLAKE2b-256 077e0d8838972ffead497b40cd42a1676f9ad90427d422c92dff2fb5461c4308

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page