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.28.tar.gz (754.0 kB view details)

Uploaded Source

Built Distribution

langchain_openai-0.3.28-py3-none-any.whl (70.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_openai-0.3.28.tar.gz
  • Upload date:
  • Size: 754.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.28.tar.gz
Algorithm Hash digest
SHA256 6c669548dbdea325c034ae5ef699710e2abd054c7354fdb3ef7bf909dc739d9e
MD5 a808897169a3ae35799ee6015b1b08e5
BLAKE2b-256 6b1d90cd764c62d5eb822113d3debc3abe10c8807d2c0af90917bfe09acd6f86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_openai-0.3.28-py3-none-any.whl
Algorithm Hash digest
SHA256 4cd6d80a5b2ae471a168017bc01b2e0f01548328d83532400a001623624ede67
MD5 490c3ed5b3b4a9c670518af453c66776
BLAKE2b-256 915675f3d84b69b8bdae521a537697375e1241377627c32b78edcae337093502

See more details on using hashes here.

Supported by

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