Files
langchain/libs/partners
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
..

FAQ

Looking for an integration not listed here? Check out the integrations documentation and the note in the libs/ README about third-party maintained packages.

Integration docs

For full documentation, see the primary and API reference docs for integrations.