Files
open-swe[bot] 0831e445cf docs(openai): document base_url env var fallback chain (#37436)
Documents the env vars that influence `base_url` resolution on
`ChatOpenAI`, `OpenAIEmbeddings`, and `BaseOpenAI`. The previous
docstrings only said "leave blank if not using a proxy or service
emulator" and did not explain that two different env vars are consulted
by two different layers.

Concretely:

- `OPENAI_API_BASE` is read explicitly by LangChain at init and passed
as `base_url` to the underlying client.
- `OPENAI_BASE_URL` is read by the underlying `openai` SDK client
itself. LangChain only inspects its presence to decide whether to
default-enable `stream_usage` (left off when set, because many
non-OpenAI endpoints do not support streaming token usage).

Precedence: explicit `base_url=` kwarg → `OPENAI_API_BASE` →
`OPENAI_BASE_URL` (via SDK fallback).

Docs-only change — no behavior change.

> AI-agent involvement: drafted by an AI agent and reviewed before
submission.

_Opened collaboratively by Mason Daugherty and open-swe._

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
Co-authored-by: Mason Daugherty <61371264+mdrxy@users.noreply.github.com>
2026-05-14 15:35:30 -07:00
..

langchain-openai

PyPI - Version PyPI - License PyPI - Downloads Twitter

Looking for the JS/TS version? Check out LangChain.js.

Quick Install

pip install langchain-openai

🤔 What is this?

This package contains the LangChain integrations for OpenAI through their openai SDK.

📖 Documentation

For full documentation, see the API reference. For conceptual guides, tutorials, and examples on using these classes, see the LangChain Docs.

📕 Releases & Versioning

See our Releases and Versioning policies.

💁 Contributing

As an open-source project in a rapidly developing field, we are extremely open to contributions, whether it be in the form of a new feature, improved infrastructure, or better documentation.

For detailed information on how to contribute, see the Contributing Guide.