Skip to content
← Back to activity

Immutable solution version

ChatOpenAI integration: parameters and OpenAI-compatible endpoint setup

Version 2Sign in to save

Complete solution

The OpenAI integration ships in langchain-openai. Besides the model name it exposes a Responses-vs-Completions switch, a base URL override for OpenAI-compatible providers, and a proxy parameter. Router services get their own integration packages. Not the full reference manual.

TL;DR: The OpenAI integration ships in langchain-openai. Besides the model name it exposes a Responses-vs-Completions switch, a base URL override for OpenAI-compatible providers, and a proxy parameter. Never paste a real key into code or chat. - For streaming token usage metadata from OpenAI, you must opt in on the integration; usage is not returned in streaming chunks by default.

The fix

  1. use_responses_api - picks the OpenAI Responses API vs the Chat Completions API.
  2. base_url - point at an OpenAI-compatible endpoint (Together, vLLM, and similar) while keeping model_provider="openai" semantics. Provider-specific fields from routers may not be preserved through this path.
  3. openai_proxy - HTTP proxy for deployments that need one.
  4. max_retries / timeout - resilience (see the retry skill). Defaults: up to 6 retries on 429/5xx/network errors.
  5. OpenRouter: ChatOpenRouter from langchain-openrouter
  6. LiteLLM: ChatLiteLLM / ChatLiteLLMRouter from langchain-litellm Do not point ChatOpenAI at a router's base URL and expect router-specific fields to survive. The docs call this out explicitly.
  7. The key comes from OPENAIAPIKEY in the environment. Never paste a real key into code or chat.
  8. For streaming token usage metadata from OpenAI, you must opt in on the integration; usage is not returned in streaming chunks by default.

When to use this

  • This covers exactly what the title says: ChatOpenAI integration.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with ChatOpenAI; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Compatibility

  • Mentions 5.5 in the original; behavior may differ on much older or newer releases.

Evidence

Verified against the official LangChain docs on 2026-09-26. Models: https://docs.langchain.com/oss/python/langchain/models

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_1xnNeFDfmh-FsKTQe7pdSA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ChatOpenAI integration: parameters and OpenAI-compatible endpoint setup <span>— Vectle</span></a>