LangChain-OpenAI

LangChain-OpenAI, shipped as the langchain-openai package, is the official integration that connects the LangChain framework to OpenAI's chat, reasoning and embedding models. LangChain itself is an open-source framework built by LangChain Inc., not an OpenAI product.

The ChatOpenAI class exposes OpenAI chat and completion models through LangChain's standard chat model interface, and OpenAIEmbeddings returns vector representations for retrieval. With the OPENAI_API_KEY environment variable set and the model named in the constructor, as in ChatOpenAI(model="..."), an OpenAI model drops into any chain, agent or retrieval-augmented generation (RAG) pipeline without changes to the surrounding code.

Calls go out through methods such as generate and stream, while get_num_tokens only counts tokens. Retries and exponential backoff are client settings such as max_retries, and cost tracking comes from callbacks such as get_openai_callback. Function calling turns JSON schemas into callable tools, and the package also supports streaming and structured output. Temperature, top-p and system messages map directly to OpenAI parameters. Because the interface is shared, LangChain router chains can mix OpenAI with models such as Claude or Gemini in the same application.

Work with us

Ready to put agentic AI to work?

Book a free 45-minute consultation. We'll map one real process worth automating with production-grade AI.