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.1.tar.gz (48.2 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.1-py3-none-any.whl (54.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_openai-0.3.1.tar.gz
  • Upload date:
  • Size: 48.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for langchain_openai-0.3.1.tar.gz
Algorithm Hash digest
SHA256 cce314f1437b2cad73e0ed2b55e74dc399bc1bbc43594c4448912fb51c5e4447
MD5 6c6d49739a5a8d0c649c0f2e42414c9f
BLAKE2b-256 85018fa0e1a708f1634a88df0c239f1e9733a2848c62fcd6aaea08cee4857ec1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_openai-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5cf2a1e115b12570158d89c22832fa381803c3e1e11d1eb781195c8d9e454bd5
MD5 4cb5d6a3bb54a93917d41acd6726abb2
BLAKE2b-256 8d9e388aaa4a727e86c3f61238df059a0d438de1a68ee369957182436d976a8a

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