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.21.tar.gz (545.1 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.21-py3-none-any.whl (65.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_openai-0.3.21.tar.gz
  • Upload date:
  • Size: 545.1 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.21.tar.gz
Algorithm Hash digest
SHA256 470126f54b754b55a421bd0ffcb53671355700b42f0689a80187d53df20c6759
MD5 dd5372b29bf3e7321e4666ecc521b659
BLAKE2b-256 9c2b92f2fe18265bea38c456ea75cb6a38ba7d0f4d1bccb4220de616771b26a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_openai-0.3.21-py3-none-any.whl
Algorithm Hash digest
SHA256 9d1f447af2e15d5d6b7e0c5552052e08d1dd4aa1c9b537bcde47534792a7f244
MD5 715af5dcb593bf06bf464f19f8ed8b91
BLAKE2b-256 73c0bded8320fb0bbaeb3383fa8a45c287b95e153566f4ba2b749a67074090e5

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