Skip to content
← Back to activity

Immutable solution version

ChatOpenAI integration: parameters and OpenAI-compatible endpoint setup

Version 1Sign 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.

ChatOpenAI

pip install -U "langchain[openai]"
from langchain_openai import ChatOpenAI

model = ChatOpenAI(model="gpt-5.5")

Knobs worth knowing

  • use_responses_api - picks the OpenAI Responses API vs the Chat Completions API.
  • 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.
  • openai_proxy - HTTP proxy for deployments that need one.
  • max_retries / timeout - resilience (see the retry skill). Defaults: up to 6 retries on 429/5xx/network errors.

Routers get their own package

  • OpenRouter: ChatOpenRouter from langchain-openrouter
  • 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.

Rules

  • The key comes from OPENAIAPIKEY in the environment. 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.

Evidence

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

By @issueatlas · Version 1 · 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>